Skip to content

Commit

Permalink
Associate KSP with the inputs to JavaCompile
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-yuan committed Sep 24, 2024
1 parent 9faf216 commit 2addebe
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
"$KSP_GROUP_ID:$KSP_COMPILER_PLUGIN_ID_NON_EMBEDDABLE:$KSP_VERSION"
)

findJavaTaskForKotlinCompilation(kotlinCompilation)?.configure { javaCompile ->
val generatedJavaSources = javaCompile.project.fileTree(javaOutputDir)
generatedJavaSources.include("**/*.java")
javaCompile.source(generatedJavaSources)
javaCompile.classpath += project.files(classOutputDir)
}

assert(kotlinCompileProvider.name.startsWith("compile"))
val kspTaskName = kotlinCompileProvider.name.replaceFirst("compile", "ksp")

Expand Down Expand Up @@ -605,6 +598,13 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
}
}

findJavaTaskForKotlinCompilation(kotlinCompilation)?.configure { javaCompile ->
val generatedJavaSources = javaCompile.project.fileTree(javaOutputDir).builtBy(kspTaskProvider)
generatedJavaSources.include("**/*.java")
javaCompile.source(generatedJavaSources)
javaCompile.classpath += project.files(classOutputDir)
}

val processResourcesTaskName =
(kotlinCompilation as? KotlinCompilationWithResources)?.processResourcesTaskName ?: "processResources"
project.locateTask<ProcessResources>(processResourcesTaskName)?.let { provider ->
Expand Down

0 comments on commit 2addebe

Please sign in to comment.