diff options
author | Ting-Yuan Huang <laszio@google.com> | 2023-10-05 12:30:05 -0700 |
---|---|---|
committer | laszio <ting-yuan@users.noreply.github.com> | 2023-10-05 16:25:18 -0700 |
commit | 4787ae113960f3af2a22d616ff50f10083a6538f (patch) | |
tree | 10d06eec7ea3f67ff9c473c956b9909ceb8c8532 | |
parent | 9ead65375cf248b5e15b2757b270ef3a493a836e (diff) | |
download | ksp-4787ae113960f3af2a22d616ff50f10083a6538f.tar.gz |
Add generated source set with new KGP API
KotlinCompilation.source() is deprecated.
(cherry picked from commit fbeec1f5e5eeb74d16096f3fa8f983d2269d0ec1)
-rw-r--r-- | gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt index df194590..f0c0365b 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt @@ -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)) |