I had a project library in Eclipse with Maven and the generated jar included some libraries dependencies inside. Now I am migrating to Android Studio and I would like to build the same jar. I can generate a jar with the following lines in gradle:
task clearJar(type: Delete) {
delete 'build/libs/mysdk.jar'
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('release/')
include('classes.jar')
rename ('classes.jar', 'mysdk.jar')
}
makeJar.dependsOn(clearJar, build)
But inside the jar there are not included the libraries that I use in my project library. With Maven I can use the "provided" scope in order to include or not a library in my jar but with gradle... how can I do that?
Thanks
Solved with the following tasks:
task jarTask(type: Jar) {
baseName="my-sdk-android"
from 'src/main/java'
}
task createJarWithDependencies(type: Jar) {
baseName = "my-sdk-android-jar-with-dependencies"
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jarTask
}
configurations {
jarConfiguration
}
artifacts {
jarConfiguration jarTask
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With