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
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user