Big Chungus
06/14/2022, 1:56 PMandroidMain
and androidTest
sourceSets? They seem to behave differently to other sourceSets somehow.
For instance, injecting an intermediate sourceSet doesn't seem to work with this hierarchy:
commonMain
jsMain
blockingMain
androidMain
jvmMain
linuxX64Main
I have an actual class in commonMain
which I implement in jsMain
and blockingMain
. This works fine for all the targets EXCEPT android, which complains on compilation
e: /path/File.kt: (11, 24): Expected class 'MyClass' has no actual declaration in module <my-module_release> for JVMI'm adding the dependecies like this
kotlin {
explicitApi()
android {
publishLibraryVariants("release", "debug")
}
sourceSets {
afterEvaluate { // Crashes due to missing sourceSet if we don't do this in afterEvaluate
named("androidMain") {
dependsOn(getByName("blockingMain"))
}
named("androidTest") {
dependsOn(getByName("blockingTest"))
}
}
}
}
ephemient
06/14/2022, 2:12 PMYou can have a shared source set for the following combinations of targets:
• JVM + JS + Native
• JVM + Native
• JS + Native
• JVM + JS
• Native
Kotlin doesn't currently support sharing a source set for these combinations:
• Several JVM targets
• JVM + Android targets
• Several JS targetsthat
blockingMain
isn't supportedBig Chungus
06/14/2022, 2:27 PMephemient
06/14/2022, 2:29 PMkotlin {
sourceSets {
getByName("jvmMain") {
kotlin.srcDir("src/commonJvmMain/kotlin")
}
getByName("androidMain") {
kotlin.srcDir("src/commonJvmMain/kotlin"
}
}
}
which confuses the IDE but Gradle is fine with itBig Chungus
06/14/2022, 2:30 PMSebastian Sellmair [JB]
06/16/2022, 12:57 PMBig Chungus
06/16/2022, 4:00 PMCrashes due to missing sourceSet if we don't do this in afterEvaluate
ephemient
06/16/2022, 4:08 PMsourceSets.matching { it.name == "androidMain" }.configureEach { ... }
will work regardless of when sourcesets are registered. but it's very strange that it's needed in the first place;
kotlin {
android()
sourceSets {
getByName("androidMain")
getByName("androidTest")
should work fine, and does for meBig Chungus
06/16/2022, 4:08 PMephemient
06/16/2022, 4:09 PM