Kapt: Disable location mapping by default, allow to enable it manually
This commit is contained in:
+26
@@ -301,6 +301,32 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLocationMapping() {
|
||||
val project = Project("locationMapping", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
|
||||
project.build("build") {
|
||||
assertFailed()
|
||||
|
||||
assertContains("Test.java:9: error: GenError element")
|
||||
assertContains("Test.java:17: error: GenError element")
|
||||
}
|
||||
|
||||
project.projectDir.getFileByName("build.gradle").modify {
|
||||
it.replace("mapDiagnosticLocations = false", "mapDiagnosticLocations = true")
|
||||
}
|
||||
|
||||
project.build("build") {
|
||||
assertFailed()
|
||||
|
||||
assertNotContains("Test.java:9: error: GenError element")
|
||||
assertNotContains("Test.java:17: error: GenError element")
|
||||
|
||||
assertContains("test.kt:3: error: GenError element")
|
||||
assertContains("test.kt:7: error: GenError element")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangesInLocalAnnotationProcessor() {
|
||||
val project = Project("localAnnotationProcessor", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-kapt"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
kapt {
|
||||
mapDiagnosticLocations = false
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package example
|
||||
|
||||
class Test {
|
||||
@field:example.GenError
|
||||
val a: String
|
||||
|
||||
fun b(@example.GenError a: Boolean) {}
|
||||
}
|
||||
+1
@@ -278,6 +278,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
|
||||
pluginOptions += SubpluginOption("useLightAnalysis", "${kaptExtension.useLightAnalysis}")
|
||||
pluginOptions += SubpluginOption("correctErrorTypes", "${kaptExtension.correctErrorTypes}")
|
||||
pluginOptions += SubpluginOption("mapDiagnosticLocations", "${kaptExtension.mapDiagnosticLocations}")
|
||||
pluginOptions += FilesSubpluginOption("stubs", listOf(getKaptStubsDir()))
|
||||
|
||||
if (project.hasProperty(VERBOSE_OPTION_NAME) && project.property(VERBOSE_OPTION_NAME) == "true") {
|
||||
|
||||
+2
@@ -30,6 +30,8 @@ open class KaptExtension {
|
||||
|
||||
open var correctErrorTypes: Boolean = false
|
||||
|
||||
open var mapDiagnosticLocations: Boolean = false
|
||||
|
||||
open var processors: String = ""
|
||||
|
||||
/** Explicit opt-in switch for Kapt caching. Should be used when annotation processors used by this project are
|
||||
|
||||
+4
@@ -55,6 +55,9 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||
@Parameter
|
||||
private boolean correctErrorTypes = false;
|
||||
|
||||
@Parameter
|
||||
private boolean mapDiagnosticLocations = false;
|
||||
|
||||
@Parameter
|
||||
private List<String> annotationProcessorArgs;
|
||||
|
||||
@@ -94,6 +97,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||
options.add(new KaptOption("aptOnly", true));
|
||||
options.add(new KaptOption("useLightAnalysis", useLightAnalysis));
|
||||
options.add(new KaptOption("correctErrorTypes", correctErrorTypes));
|
||||
options.add(new KaptOption("mapDiagnosticLocations", mapDiagnosticLocations));
|
||||
options.add(new KaptOption("processors", annotationProcessors));
|
||||
|
||||
if (arguments.getVerbose()) {
|
||||
|
||||
Reference in New Issue
Block a user