Do not remove annotations.txt (kapt1) file before kotlin compiler is called

#KT-14250 fixed

 Before this change the following could happen:
 0. Successful build.
 1. Only java files are changed.
 2. CompileKotlin task starts because java files are also input files for kotlin.
 3. annotations.txt file is deleted, but kotlin compiler is not called, so it is not regenerated.
 4. Javac fails.
This commit is contained in:
Alexey Tsvetkov
2016-10-20 18:33:48 +03:00
parent 770ea75138
commit b7d97a3aa2
3 changed files with 22 additions and 1 deletions
@@ -202,4 +202,22 @@ class KaptIT: BaseGradleIT() {
assertCompiledKotlinSources(project.relativize(internalDummyUserKt, internalDummyTestKt))
}
}
@Test
fun testKotlinCompilerNotCalledStubsIC() {
val options = defaultBuildOptions().copy(incremental = true)
val project = Project("kaptStubs", GRADLE_VERSION)
project.build("build", options = options) {
assertSuccessful()
}
val javaDummy = project.projectDir.getFileByName("JavaDummy.java")
javaDummy.modify { it + " " }
project.build("build", options = options) {
assertSuccessful()
assertCompiledKotlinSources(emptyList())
}
}
}
@@ -0,0 +1,4 @@
package javaPackage;
public class JavaDummy {
}
@@ -534,7 +534,6 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
kaptAnnotationsFileUpdater = AnnotationFileUpdater(kaptAnnotationsFile)
}
if (kaptAnnotationsFile.exists()) kaptAnnotationsFile.delete()
pluginOptions.addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "output", kaptAnnotationsFile.canonicalPath)
}