Kapt3: Do not generate "options not recognized" for "kapt.kotlin.generated" option (KT-17418)

"kapt.kotlin.generated" AP option is always present (and it's the way to say the arbitrary processors about the target directory for generated Kotlin source files).
In this commit, the "fake" empty annotation processor is added to consume the option if no other processor does it.
This commit is contained in:
Yan Zhulanow
2017-04-19 18:06:29 +03:00
committed by Yan Zhulanow
parent c970763a7f
commit 20e362e363
2 changed files with 9 additions and 0 deletions
@@ -75,6 +75,7 @@ class Kapt3IT : BaseGradleIT() {
assertFileExists("build/classes/main/example/RuntimeAnnotatedTestClassGenerated.class")
assertContains("example.JavaTest PASSED")
assertClassFilesNotContain(File(project.projectDir, "build/classes"), "ExampleSourceAnnotation")
assertNotContains("warning: The following options were not recognized by any processor")
}
project.build("build") {
@@ -43,6 +43,14 @@ class KaptJavaLog(
return
}
if (diagnostic.type == JCDiagnostic.DiagnosticType.WARNING
&& diagnostic.code == "compiler.warn.proc.unmatched.processor.options"
&& diagnostic.args.singleOrNull() == "[kapt.kotlin.generated]"
) {
// Do not report the warning about "kapt.kotlin.generated" option being ignored if it's the only ignored option
return
}
val targetElement = diagnostic.diagnosticPosition
if (diagnostic.code.contains("err.cant.resolve") && targetElement != null) {
val sourceFile = interceptorData.files[diagnostic.source]