KT-34167: Warn when incremental AP does not follow the contract

Isolating incremental AP must report exactly one originating source file.
This commit logs a warning when this constraint is violated.

Test: AnnotationProcessorDependencyCollectorTest.testIsolatingWithoutOrigin
This commit is contained in:
Ivan Gavrilovic
2019-10-15 17:44:21 +01:00
committed by Yan Zhulanow
parent 8f94a71de7
commit 4e807692e5
7 changed files with 34 additions and 18 deletions
@@ -26,6 +26,7 @@ import javax.lang.model.element.TypeElement
class JavaKaptContextTest : TestCase() {
companion object {
private val TEST_DATA_DIR = File("plugins/kapt3/kapt3-base/testData/runner")
val logger = WriterBackedKaptLogger(isVerbose = true)
fun simpleProcessor() = IncrementalProcessor(
object : AbstractProcessor() {
@@ -52,7 +53,7 @@ class JavaKaptContextTest : TestCase() {
}
override fun getSupportedAnnotationTypes() = setOf("test.MyAnnotation")
}, DeclaredProcType.NON_INCREMENTAL
}, DeclaredProcType.NON_INCREMENTAL, logger
)
}
@@ -69,7 +70,6 @@ class JavaKaptContextTest : TestCase() {
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
}.build()
val logger = WriterBackedKaptLogger(isVerbose = true)
KaptContext(options, true, logger).doAnnotationProcessing(listOf(javaSourceFile), listOf(processor))
}
@@ -99,7 +99,7 @@ class JavaKaptContextTest : TestCase() {
}
try {
doAnnotationProcessing(File(TEST_DATA_DIR, "Simple.java"), IncrementalProcessor(processor, DeclaredProcType.NON_INCREMENTAL), TEST_DATA_DIR)
doAnnotationProcessing(File(TEST_DATA_DIR, "Simple.java"), IncrementalProcessor(processor, DeclaredProcType.NON_INCREMENTAL, logger), TEST_DATA_DIR)
} catch (e: KaptBaseError) {
assertEquals(KaptBaseError.Kind.EXCEPTION, e.kind)
assertEquals("Here we are!", e.cause!!.message)