Thank you for the reply! But with such an approach resulting LibraryProject.aar will not have all dependencies packaged, unless I'm missing something.
What I'm doing right now is manually adding compiled classes to libs before packageLibrary task. Works in my particular case, but obviously ugly, looks like a hack does not work with resources, manifests and etc. What is the better gradle/android-library way?
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)