KT-35472: Detect when content of annotation processor changes
Even if annotation processor classpath is the same, in case individual entries change (e.g. bulding annotationo processor from source), KATP should run non-incrementally. Test: KaptIncrementalWithIsolatingApt.testUnchangedAnnotationProcessorClasspathButContentChanged
This commit is contained in:
committed by
Yan Zhulanow
parent
7b227f3113
commit
62924ddcd4
+27
@@ -95,6 +95,33 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testUnchangedAnnotationProcessorClasspathButContentChanged() {
|
||||||
|
val project = getProject()
|
||||||
|
val processorJar = project.projectDir.resolve("processor.jar").also { it.createNewFile() }
|
||||||
|
project.gradleBuildScript().appendText(
|
||||||
|
"""
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
kapt files("processor.jar")
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
project.build("clean", "build") {
|
||||||
|
assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
ZipOutputStream(processorJar.outputStream()).use {
|
||||||
|
it.putNextEntry(ZipEntry("resource.txt"))
|
||||||
|
it.closeEntry()
|
||||||
|
}
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertContains("Unable to use existing data, re-initializing classpath information for KAPT.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNonIncrementalWithUnrecognizedInputs() {
|
fun testNonIncrementalWithUnrecognizedInputs() {
|
||||||
val project = getProject()
|
val project = getProject()
|
||||||
|
|||||||
+4
@@ -69,6 +69,10 @@ open class ClasspathSnapshot protected constructor(
|
|||||||
if (!isCompatible(previousSnapshot)) {
|
if (!isCompatible(previousSnapshot)) {
|
||||||
return KaptClasspathChanges.Unknown
|
return KaptClasspathChanges.Unknown
|
||||||
}
|
}
|
||||||
|
if (annotationProcessorClasspath.any { it in changedFiles }) {
|
||||||
|
// in case annotation processor classpath changes, we have to run non-incrementally
|
||||||
|
return KaptClasspathChanges.Unknown
|
||||||
|
}
|
||||||
|
|
||||||
val unchangedBetweenCompilations = dataForFiles.keys.intersect(previousSnapshot.dataForFiles.keys).filter { it !in changedFiles }
|
val unchangedBetweenCompilations = dataForFiles.keys.intersect(previousSnapshot.dataForFiles.keys).filter { it !in changedFiles }
|
||||||
val currentToLoad = dataForFiles.keys.filter { it !in unchangedBetweenCompilations }.also { loadEntriesFor(it) }
|
val currentToLoad = dataForFiles.keys.filter { it !in unchangedBetweenCompilations }.also { loadEntriesFor(it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user