From 20e362e363deea2dab37771af9984af804fa5b81 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Wed, 19 Apr 2017 18:06:29 +0300 Subject: [PATCH] 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. --- .../test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt | 1 + .../src/org/jetbrains/kotlin/kapt3/javac/KaptJavaLog.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt index 30b986d605d..8051d39dafc 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt @@ -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") { diff --git a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/javac/KaptJavaLog.kt b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/javac/KaptJavaLog.kt index c5e0ee09d9f..ce3034c1d69 100644 --- a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/javac/KaptJavaLog.kt +++ b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/javac/KaptJavaLog.kt @@ -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]