Delete output when unable to run KAPT incrementally
When comparing previous and current classpath snapshots, and it is not possible to compute the types that changed, make sure to delete the outputs before invoking KAPT. Test: KaptIncrementalWithAggregatingApt.testIncompatibleClasspathChanges
This commit is contained in:
committed by
Yan Zhulanow
parent
e4f9314f94
commit
2412b5f992
+34
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertFalse
|
||||
|
||||
class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
|
||||
@@ -136,4 +137,37 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
assertTrue(getProcessedSources(output).isEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncompatibleClasspathChanges() {
|
||||
val project = getProject()
|
||||
project.projectFile("useB.kt").modify { current ->
|
||||
current + """
|
||||
|
||||
@example.ExampleAnnotation
|
||||
fun addedFunctionB() = ""
|
||||
""".trimIndent()
|
||||
}
|
||||
project.build("clean", "build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
project.projectFile("useB.kt").modify { current ->
|
||||
current.replace("fun addedFunctionB", "fun renamedFunctionB")
|
||||
}
|
||||
project.gradleBuildScript().appendText("""
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.guava:guava:12.0'
|
||||
}
|
||||
""".trimIndent())
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
assertFalse(
|
||||
fileInWorkingDir("build/generated/source/kapt/main/bar/AddedFunctionBGenerated.java").exists(),
|
||||
"Generated file should be deleted for renamed function when classpath changes."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user