I would like to split an Android library project into modules. The intended project structure is:
├─ androidLibraryModule
│
├─ kotlinLibraryModuleA
│
└─ kotlinLibraryModuleB
Where androidLibraryModule depends on kotlinLibraryModuleA and kotlinLibraryModuleB:
dependencies {
implementation project(":kotlinLibraryModuleA")
implementation project(":kotlinLibraryModuleB")
}
The only thing I'll publish is the .aar which is the result of building androidLibraryModule and I would like it to include the code from kotlinLibraryModuleA and kotlinLibraryModuleA.
The only way I've found so far to achieve this goal is by copying the .jar files of kotlinLibraryModuleA and kotlinLibraryModuleB into the libs folder of androidLibraryModule this way:
task copyJar(type: Copy) {
from jar
into "${project(":androidLibraryModule").projectDir.absolutePath}/libs"
}
jar.finalizedBy(copyJar)
This solution works but feels a bit like a hack. Is this the only solution or is there a better way to achieve this result?
EDIT: if androidLibraryModule was an Android application module, this would just work without the need for a copy task.