Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm developing a library on Android Studio (a SDK, let's say module A). To test it out, I also got a demoApp

I also have another lib with the SDK dependencies (a plugin, let's say module B)

So in my project, there are 3 modules : the SDK (A), the demoApp and the plugin (B)

Now I need to distribute my SDK and / or my plugin in jar files so people can use it in their project

The question is : how can I generate a jar for the SDK and a jar for the plugin (including all the necessaries dependencies of course like jar in libs folder) with Gradle tasks (I don't need any ressources or assets) ?

I'm very new to Gradle, I cross this answer but I don't know if it match my needs (need to be Android compatible)

EDIT : to clarify I added letter

  • I need a jar file for A
  • B need A to run (dependencies)
  • I need a jar file for B
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
242 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to create a new gradle task, similar to mine

task clearJar(type: Delete) {
    delete '../location/' + LIBRARY_NAME + '_' + LIBRARY_VERSION + '.jar'
}

task makeJar(type: Copy) {
    dependsOn clearJar, build
    from 'build/intermediates/bundles/release/'
    into '../../location/'
    include 'classes.jar'
    rename 'classes.jar', LIBRARY_NAME + '_' + LIBRARY_VERSION + '.jar'
}

Where LIBRARY_NAME and LIBRARY_VERSION are strings I set at the top of the gradle build file.

You can add this task and then select it like this

this


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...