Merge "Repeat kapt processor argument for multiple processors" am: 52c0b7b35b
Change-Id: Ifb56e6cac2dd38c96be1ed3e0153258301469d51
This commit is contained in:
@@ -196,7 +196,7 @@ type javaBuilderFlags struct {
|
|||||||
classpath classpath
|
classpath classpath
|
||||||
java9Classpath classpath
|
java9Classpath classpath
|
||||||
processorPath classpath
|
processorPath classpath
|
||||||
processor string
|
processors []string
|
||||||
systemModules *systemModules
|
systemModules *systemModules
|
||||||
aidlFlags string
|
aidlFlags string
|
||||||
aidlDeps android.Paths
|
aidlDeps android.Paths
|
||||||
@@ -270,8 +270,8 @@ func emitXrefRule(ctx android.ModuleContext, xrefFile android.WritablePath, idx
|
|||||||
deps = append(deps, flags.processorPath...)
|
deps = append(deps, flags.processorPath...)
|
||||||
|
|
||||||
processor := "-proc:none"
|
processor := "-proc:none"
|
||||||
if flags.processor != "" {
|
if len(flags.processors) > 0 {
|
||||||
processor = "-processor " + flags.processor
|
processor = "-processor " + strings.Join(flags.processors, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
intermediatesDir := "xref"
|
intermediatesDir := "xref"
|
||||||
@@ -385,8 +385,8 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
|
|||||||
deps = append(deps, flags.processorPath...)
|
deps = append(deps, flags.processorPath...)
|
||||||
|
|
||||||
processor := "-proc:none"
|
processor := "-proc:none"
|
||||||
if flags.processor != "" {
|
if len(flags.processors) > 0 {
|
||||||
processor = "-processor " + flags.processor
|
processor = "-processor " + strings.Join(flags.processors, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
srcJarDir := "srcjars"
|
srcJarDir := "srcjars"
|
||||||
|
@@ -1134,7 +1134,8 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||||||
flags.java9Classpath = append(flags.java9Classpath, deps.java9Classpath...)
|
flags.java9Classpath = append(flags.java9Classpath, deps.java9Classpath...)
|
||||||
flags.processorPath = append(flags.processorPath, deps.processorPath...)
|
flags.processorPath = append(flags.processorPath, deps.processorPath...)
|
||||||
|
|
||||||
flags.processor = strings.Join(deps.processorClasses, ",")
|
flags.processors = append(flags.processors, deps.processorClasses...)
|
||||||
|
flags.processors = android.FirstUniqueStrings(flags.processors)
|
||||||
|
|
||||||
if len(flags.bootClasspath) == 0 && ctx.Host() && !flags.javaVersion.usesJavaModules() &&
|
if len(flags.bootClasspath) == 0 && ctx.Host() && !flags.javaVersion.usesJavaModules() &&
|
||||||
decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() {
|
decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() {
|
||||||
@@ -1269,7 +1270,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
srcJars = append(srcJars, kaptSrcJar)
|
srcJars = append(srcJars, kaptSrcJar)
|
||||||
// Disable annotation processing in javac, it's already been handled by kapt
|
// Disable annotation processing in javac, it's already been handled by kapt
|
||||||
flags.processorPath = nil
|
flags.processorPath = nil
|
||||||
flags.processor = ""
|
flags.processors = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName)
|
kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName)
|
||||||
|
@@ -136,8 +136,11 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||||||
kaptProcessorPath := flags.processorPath.FormRepeatedClassPath("-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=")
|
kaptProcessorPath := flags.processorPath.FormRepeatedClassPath("-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=")
|
||||||
|
|
||||||
kaptProcessor := ""
|
kaptProcessor := ""
|
||||||
if flags.processor != "" {
|
for i, p := range flags.processors {
|
||||||
kaptProcessor = "-P plugin:org.jetbrains.kotlin.kapt3:processors=" + flags.processor
|
if i > 0 {
|
||||||
|
kaptProcessor += " "
|
||||||
|
}
|
||||||
|
kaptProcessor += "-P plugin:org.jetbrains.kotlin.kapt3:processors=" + p
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedJavacFlags := kaptEncodeFlags([][2]string{
|
encodedJavacFlags := kaptEncodeFlags([][2]string{
|
||||||
|
@@ -88,7 +88,7 @@ func TestKapt(t *testing.T) {
|
|||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java", "b.kt"],
|
srcs: ["a.java", "b.kt"],
|
||||||
plugins: ["bar"],
|
plugins: ["bar", "baz"],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_plugin {
|
java_plugin {
|
||||||
@@ -96,6 +96,12 @@ func TestKapt(t *testing.T) {
|
|||||||
processor_class: "com.bar",
|
processor_class: "com.bar",
|
||||||
srcs: ["b.java"],
|
srcs: ["b.java"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_plugin {
|
||||||
|
name: "baz",
|
||||||
|
processor_class: "com.baz",
|
||||||
|
srcs: ["b.java"],
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := android.BuildOs.String()
|
||||||
@@ -105,6 +111,7 @@ func TestKapt(t *testing.T) {
|
|||||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||||
|
|
||||||
bar := ctx.ModuleForTests("bar", buildOS+"_common").Rule("javac").Output.String()
|
bar := ctx.ModuleForTests("bar", buildOS+"_common").Rule("javac").Output.String()
|
||||||
|
baz := ctx.ModuleForTests("baz", buildOS+"_common").Rule("javac").Output.String()
|
||||||
|
|
||||||
// Test that the kotlin and java sources are passed to kapt and kotlinc
|
// 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" {
|
if len(kapt.Inputs) != 2 || kapt.Inputs[0].String() != "a.java" || kapt.Inputs[1].String() != "b.kt" {
|
||||||
@@ -136,11 +143,12 @@ func TestKapt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test that the processors are passed to kapt
|
// Test that the processors are passed to kapt
|
||||||
expectedProcessorPath := "-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=" + bar
|
expectedProcessorPath := "-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=" + bar +
|
||||||
|
" -P plugin:org.jetbrains.kotlin.kapt3:apclasspath=" + baz
|
||||||
if kapt.Args["kaptProcessorPath"] != expectedProcessorPath {
|
if kapt.Args["kaptProcessorPath"] != expectedProcessorPath {
|
||||||
t.Errorf("expected kaptProcessorPath %q, got %q", expectedProcessorPath, kapt.Args["kaptProcessorPath"])
|
t.Errorf("expected kaptProcessorPath %q, got %q", expectedProcessorPath, kapt.Args["kaptProcessorPath"])
|
||||||
}
|
}
|
||||||
expectedProcessor := "-P plugin:org.jetbrains.kotlin.kapt3:processors=com.bar"
|
expectedProcessor := "-P plugin:org.jetbrains.kotlin.kapt3:processors=com.bar -P plugin:org.jetbrains.kotlin.kapt3:processors=com.baz"
|
||||||
if kapt.Args["kaptProcessor"] != expectedProcessor {
|
if kapt.Args["kaptProcessor"] != expectedProcessor {
|
||||||
t.Errorf("expected kaptProcessor %q, got %q", expectedProcessor, kapt.Args["kaptProcessor"])
|
t.Errorf("expected kaptProcessor %q, got %q", expectedProcessor, kapt.Args["kaptProcessor"])
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user