AAR with included subprojects (JARs & AAR)

Hello! Have a problem to make distribution of single AAR from several subprojects.
Here is sample codebase with 2 pure java modules and 2 android libraries: https://github.com/Uthering/sample-subprojects-in-aar.
The main project is project-lib for which I want to have project-lib-debug.aar and project-lib-release.aar. And those files should have all the classes from pure javas and another library included. Yet, I have no luck to make this :-/
I know that it is not very good practice to include dependencies. Yet, the goal is to give the most simple solution for our partner to inject our codebase. And all the dependencies included are logical parts and seems not to be able to cause conflicts.
Any ideas how to put all the classes in classes.jar of single AAR? Thanks in advance!

I resolved my issue by collecting all dependencies inside libs folder of produced AAR at compile time. Here is working sample: https://github.com/Uthering/sample-subprojects-in-aar.
So, what one should know to make this works… it is inside diff https://github.com/Uthering/sample-subprojects-in-aar/commit/fdfa1e5edadd1cdd30d725866659fedfda73cfed?diff=unified =o) Of course, .gradle files are most important.

Some notes:

  • only java classes from subprojects are assembled, no resources or other Android stuff
  • add dependency fileTree for libs folder
  • add android.publishNonDefault=true for each AAR subproject
  • add debug and release configurations for each AAR subproject
  • add appropriate debugCompile and releaseCompile dependencies for each AAR subproject
  • gather all subprojects before bundle step
  • use AAR project as dependency inside normal app with transitive=false if app is also included in workspace

So, my problem is solved… at last :o)