diff options
author | Colin Cross <ccross@android.com> | 2019-01-23 15:39:50 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-01-23 16:14:21 -0800 |
commit | 3a3e94c09a68ff49686f78f9c8a862e2d646bf7d (patch) | |
tree | 2e6ac70c04f7c6496f7ca925ea141ca8acad8a76 /java/kotlin_test.go | |
parent | 9f100ca0e3a80cf3ae3fc1db92e7f0c0c0eec5f5 (diff) |
Fix kotlin annotation processing after java_plugin
I37c1e80eba71ae2d6a06199fb102194a51994989 broke kotlin annotation
processing with a typo in the processors flag to kapt and by
passing -processor to javac with an empty processorpath.
Bug: 77284273
Bug: 122251693
Test: kotlin_test.go
Test: m checkbuild
Change-Id: I17c45d5b3f9df089231af5d2930646ad0e6bf9be
Diffstat (limited to 'java/kotlin_test.go')
-rw-r--r-- | java/kotlin_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/java/kotlin_test.go b/java/kotlin_test.go index 3deea1373..9406ef9d7 100644 --- a/java/kotlin_test.go +++ b/java/kotlin_test.go @@ -15,6 +15,7 @@ package java import ( + "android/soong/android" "strconv" "strings" "testing" @@ -92,13 +93,19 @@ func TestKapt(t *testing.T) { java_plugin { name: "bar", + processor_class: "com.bar", + srcs: ["b.java"], } `) + buildOS := android.BuildOs.String() + kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt") kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc") javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") + bar := ctx.ModuleForTests("bar", buildOS+"_common").Rule("javac").Output.String() + // Test that the kotlin and java sources are passed to kapt and kotlinc if len(kapt.Inputs) != 2 || kapt.Inputs[0].String() != "a.java" || kapt.Inputs[1].String() != "b.kt" { t.Errorf(`foo kapt inputs %v != ["a.java", "b.kt"]`, kapt.Inputs) @@ -127,6 +134,25 @@ func TestKapt(t *testing.T) { if javac.Args["srcJars"] != kapt.Output.String() { t.Errorf("expected %q in javac srcjars %v", kapt.Output.String(), kotlinc.Args["srcJars"]) } + + // Test that the processors are passed to kapt + expectedProcessorPath := "-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=" + bar + if kapt.Args["kaptProcessorPath"] != expectedProcessorPath { + t.Errorf("expected kaptProcessorPath %q, got %q", expectedProcessorPath, kapt.Args["kaptProcessorPath"]) + } + expectedProcessor := "-P plugin:org.jetbrains.kotlin.kapt3:processors=com.bar" + if kapt.Args["kaptProcessor"] != expectedProcessor { + t.Errorf("expected kaptProcessor %q, got %q", expectedProcessor, kapt.Args["kaptProcessor"]) + } + + // Test that the processors are not passed to javac + if javac.Args["processorPath"] != "" { + t.Errorf("expected processorPath '', got %q", javac.Args["processorPath"]) + } + // TODO(b/77284273): test for -processor:none + if javac.Args["processor"] != "" { + t.Errorf("expected processor '', got %q", javac.Args["processor"]) + } } func TestKaptEncodeFlags(t *testing.T) { |