I’d like to build my android library in aar to local maven repo with an other transitive dependency.
I have a project like this :
/libA /myLib
I’d like to build myLib with libA sources packaged in myLib.aar.
the build.gradle under myLib dir :
apply plugin: 'android-library'
apply plugin: 'android-maven'
configurations {
archives {
extendsFrom configurations.default
}
}
android {
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
...
compile project(':libA') {
export = true
}
}
How can I do that ?
Thanks
It looks to me that you’re going in a right direction. Perhaps you want to take a look at various samples created by Android team that can be downloaded from http://tools.android.com/tech-docs/new-build-system (at the very bottom). mavenLocal can be of your interest. There is also documentation at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Libraries-and-Multi-project-setup
The samples do not show how to achieve what’s being asked in the OP.
Today, I’m running the same issue. I want to release a library (aar) with some other libraries dependencies in it so that our developer doesnt have to include them
I have the same needs. What I’m doing right now is manually adding compiled classes to libs before packageLibrary task. Discussion is here https://groups.google.com/forum/?utm_source=digest&utm_medium=email%2F#!topic/adt-dev/Zh_2NOUQevo
android.libraryVariants.all { variant ->
Action copyClassesAction = new Action() {
@Override
void execute(Object o) {
String variantLibsDir = getBuildDir().absolutePath + “/intermediates/bundles/” + variant.name + “/libs”
String explodedDir = getBuildDir().absolutePath + “/intermediates/exploded-aar/library-project/”
String[] dirs = new File(explodedDir).list()
for (int i = 0; i < dirs.length; i++) {
File source = new File(explodedDir + dirs[i] + “/unspecified/classes.jar”)
File destination = new File(variantLibsDir + “/” + dirs[i] + “.jar”)
destination.bytes = source.bytes
}
}
}
variant.packageLibrary.doFirst(copyClassesAction)
}