I have an existing Android app where I like to integrate a KMM library project as a git submodule. We want to integrate a git submodule on local builds and using a maven repository dependency on CI builds.
To achieve this, I added the directory of the submodule in my settings.gradle
via includeBuild
and substitute all dependencies of a specific module:
includeBuild('my-kmm-library-project') {
dependencySubstitution {
substitute module('com.example.any-kmm-artifact:any') using project(':any')
}
}
Adding
implementation 'com.example.any-kmm-artifact:any:1.0.0'
to my application build.gradle
file allows access to all classes and packages in the android sourceset int the submodule /my-kmm-library-project/any/src/androidMain
. But I have no option to import "classes" from the commonMain
sourceset. I already tried to let androidMain
depend on commonMain.
kmm/build.gradle.kts:
val androidMain by getting {
dependsOn(commonMain)
...
}
This doesn't lead to any success.
I also tried to add a jvm()
target on KMM project and let jvmMain
depend on androidMain
, but this produces compile error, cause the Android SDK classes cannot be resolved.
I think the main problem is that, the classes are just compiled into the aar which can be assembled. But the module is integrated as a gradle project implementation.
Is there a KMM option to compile "common classes" and access them through a gradle module?