Skip to content

Commit

Permalink
Add generated source set with new KGP API
Browse files Browse the repository at this point in the history
KotlinCompilation.source() is deprecated.
  • Loading branch information
ting-yuan committed Oct 5, 2023
1 parent d237d0a commit fbeec1f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,15 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
// No else; The cases should be exhaustive
}
kspGeneratedSourceSet.kotlin.srcDir(project.files(kotlinOutputDir, javaOutputDir).builtBy(kspTaskProvider))
kotlinCompilation.source(kspGeneratedSourceSet)
if (kotlinCompilation is KotlinCommonCompilation) {
// Do not make common source sets depend on generated source sets.
// They will be observed by downstreams and confuse processors.
kotlinCompileProvider.configure {
it.source(kspGeneratedSourceSet.kotlin)
}
} else {
kotlinCompilation.defaultSourceSet.dependsOn(kspGeneratedSourceSet)
}
kotlinCompileProvider.configure { kotlinCompile ->
when (kotlinCompile) {
is AbstractKotlinCompile<*> -> kotlinCompile.libraries.from(project.files(classOutputDir))
Expand Down

0 comments on commit fbeec1f

Please sign in to comment.