Davide Giuseppe Farella
04/02/2023, 9:09 PMandroidMain
)
• Android library
• Android app
As now I see them in the IDE, all the tests are ok, the app runs ok on debug and release, but somehow it crashes on TestLab (debug) because a class generated from a KMP+Android module is not there.
I'll share my current config soon in the thread.Davide Giuseppe Farella
04/02/2023, 9:14 PMtarget.extensions.configure<KotlinMultiplatformExtension> { ext ->
ext.sourceSets.getByName("commonMain").kotlin.srcDir("build/generated/ksp/jvm/jvmMain/kotlin")
}
KMP w/ android:
target.extensions.configure<KotlinMultiplatformExtension> { ext ->
ext.targetFromPreset(AndroidTargetPreset(target), ::configureAndroidTarget)
}
private fun configureAndroidTarget(target: KotlinAndroidTarget) {
target.compilations.all { compilation ->
compilation.defaultSourceSet.kotlin.srcDir(
"build/generated/ksp/${compilation.name}/kotlin"
)
}
}
Android app/lib:
target.extensions.configureIfPresent<AppExtension> { appExtension ->
appExtension.applicationVariants.all { variant ->
target.kotlinExtension.sourceSets.getByName(variant.name).kotlin.srcDir(
"build/generated/ksp/${variant.name}/kotlin"
)
}
}
target.extensions.configureIfPresent<LibraryExtension> { libraryExtension ->
libraryExtension.libraryVariants.all { variant ->
target.kotlinExtension.sourceSets.getByName(variant.name).kotlin.srcDir(
"build/generated/ksp/${variant.name}/kotlin"
)
}
}
yigit
04/02/2023, 9:42 PMyigit
04/02/2023, 9:43 PMyigit
04/02/2023, 9:44 PMDavide Giuseppe Farella
04/02/2023, 9:59 PMyigit
04/02/2023, 10:01 PMyigit
04/02/2023, 10:04 PM"build/generated/ksp/${variant.name}/kotlin"
and then do:
kotlin.srcDir(
generatorTask.flatMap { "build/generated/..."
}
)
that flatMap
(or map
) from a taskProvider tells gradle about the relationshipDavide Giuseppe Farella
04/02/2023, 10:07 PMDavide Giuseppe Farella
04/02/2023, 10:20 PMyigit
04/02/2023, 11:16 PMDavide Giuseppe Farella
04/03/2023, 5:44 AMDavide Giuseppe Farella
04/03/2023, 6:02 AMkspAndroid
in a KMP+Android module 🤦♂️Davide Giuseppe Farella
04/03/2023, 6:04 AMDavide Giuseppe Farella
04/03/2023, 6:20 AM