Problem
FeaturedPlugin registers the generateConfigParam task (output: build/generated/featured/commonMain) but does not add the output directory to any source set and does not establish a task dependency for compilation. On a plain Android (AGP) module the generated ConfigParam objects are therefore unresolved until the consumer adds manual wiring.
Manual wiring is also non-trivial on AGP 9:
kotlin { sourceSets.getByName("main") } fails at configuration time (KotlinSourceSet with name 'main' not found with AGP built-in Kotlin),
android.sourceSets["main"].kotlin.srcDir(taskProvider) is rejected by AGP ("You cannot add Provider instances to the Android SourceSet API"), so the dependency must be declared separately,
- KSP tasks (e.g. Hilt) also consume the srcDir, so the explicit dependsOn must cover
ksp* tasks too.
Working consumer-side wiring we ended up with:
android {
sourceSets.getByName("main") {
kotlin.srcDir(layout.buildDirectory.dir("generated/featured/commonMain").get().asFile)
}
}
tasks.matching {
(it.name.startsWith("compile") && it.name.contains("Kotlin")) || it.name.startsWith("ksp")
}.configureEach {
dependsOn(tasks.named("generateConfigParam"))
}
Proposal
The plugin should do this itself: react to com.android.application / com.android.library / KMP plugins and register the generated dir via the appropriate variant API (or KotlinSourceSet.kotlin.srcDir(taskProvider) on KMP where providers are accepted), so consumers get resolvable generated symbols with zero boilerplate.
Environment
Featured 1.1.1, AGP 9.0, Gradle 9.3.1, Kotlin 2.3.21, configuration cache enabled.
Problem
FeaturedPluginregisters thegenerateConfigParamtask (output:build/generated/featured/commonMain) but does not add the output directory to any source set and does not establish a task dependency for compilation. On a plain Android (AGP) module the generatedConfigParamobjects are therefore unresolved until the consumer adds manual wiring.Manual wiring is also non-trivial on AGP 9:
kotlin { sourceSets.getByName("main") }fails at configuration time (KotlinSourceSet with name 'main' not foundwith AGP built-in Kotlin),android.sourceSets["main"].kotlin.srcDir(taskProvider)is rejected by AGP ("You cannot add Provider instances to the Android SourceSet API"), so the dependency must be declared separately,ksp*tasks too.Working consumer-side wiring we ended up with:
android { sourceSets.getByName("main") { kotlin.srcDir(layout.buildDirectory.dir("generated/featured/commonMain").get().asFile) } } tasks.matching { (it.name.startsWith("compile") && it.name.contains("Kotlin")) || it.name.startsWith("ksp") }.configureEach { dependsOn(tasks.named("generateConfigParam")) }Proposal
The plugin should do this itself: react to
com.android.application/com.android.library/ KMP plugins and register the generated dir via the appropriate variant API (orKotlinSourceSet.kotlin.srcDir(taskProvider)on KMP where providers are accepted), so consumers get resolvable generated symbols with zero boilerplate.Environment
Featured 1.1.1, AGP 9.0, Gradle 9.3.1, Kotlin 2.3.21, configuration cache enabled.