Add the compiler classpath of the KotlinCompile task as KaptTask's input
KaptTask was not declaring the compiler classpath (which it takes from compileKotlin task for calling the compiler) as input. This commit fixes that and adds a test that checks compiler classpath input checks for the kapt tasks. Issue #KT-23879 Fixed
This commit is contained in:
+9
-2
@@ -72,7 +72,14 @@ class UpToDateIT : BaseGradleIT() {
|
||||
override fun initProject(project: Project) = with(project) {
|
||||
buildGradle.appendText("\nprintln 'compiler_cp=' + compileKotlin.getComputedCompilerClasspath\$kotlin_gradle_plugin()")
|
||||
build("clean") { originalCompilerCp = "compiler_cp=\\[(.*)]".toRegex().find(output)!!.groupValues[1].split(", ") }
|
||||
buildGradle.appendText("\ncompileKotlin.compilerClasspath = files($originalPaths).toList()")
|
||||
buildGradle.appendText("""${'\n'}
|
||||
// Add Kapt to the project to test its input checks as well:
|
||||
apply plugin: 'kotlin-kapt'
|
||||
compileKotlin.compilerClasspath = files($originalPaths).toList()
|
||||
afterEvaluate {
|
||||
kaptGenerateStubsKotlin.compilerClasspath = files($originalPaths).toList()
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
override fun mutateProject(project: Project) = with(project) {
|
||||
@@ -88,7 +95,7 @@ class UpToDateIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
override fun checkAfterRebuild(compiledProject: CompiledProject) = with(compiledProject) {
|
||||
assertTasksExecuted(listOf(":compileKotlin"))
|
||||
assertTasksExecuted(listOf(":compileKotlin", ":kaptGenerateStubsKotlin", ":kaptKotlin"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -45,6 +45,9 @@ open class KaptTask : ConventionTask(), CompilerArgumentAwareWithInput<K2JVMComp
|
||||
val kaptClasspath: FileCollection
|
||||
get() = project.files(*kaptClasspathConfigurations.toTypedArray())
|
||||
|
||||
@get:Classpath @get:InputFiles
|
||||
val compilerClasspath: List<File> get() = kotlinCompileTask.computedCompilerClasspath
|
||||
|
||||
@get:Internal
|
||||
internal lateinit var kaptClasspathConfigurations: List<Configuration>
|
||||
|
||||
@@ -107,7 +110,7 @@ open class KaptTask : ConventionTask(), CompilerArgumentAwareWithInput<K2JVMComp
|
||||
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
val outputItemCollector = OutputItemsCollectorImpl()
|
||||
val environment = GradleCompilerEnvironment(kotlinCompileTask.computedCompilerClasspath, messageCollector, outputItemCollector, args)
|
||||
val environment = GradleCompilerEnvironment(compilerClasspath, messageCollector, outputItemCollector, args)
|
||||
if (environment.toolsJar == null && !isAtLeastJava9) {
|
||||
throw GradleException("Could not find tools.jar in system classpath, which is required for kapt to work")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user