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.

(cherry picked from commit fbeec1f)
  • Loading branch information
ting-yuan committed Oct 5, 2023
1 parent 9ead653 commit 4787ae1
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,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 4787ae1

Please sign in to comment.