Convert javacflags -> javacopts for java_binary_host
This has already been done for java_library modules, we need to add
similar support for java_binary_host.
Bug: 213456294
Test: go test ./bp2build
Change-Id: Idf7b631f3afe9f59e50f9e45bcbdc29fb5923cc6
diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go
index 96b8958..c683b25 100644
--- a/bp2build/java_binary_host_conversion_test.go
+++ b/bp2build/java_binary_host_conversion_test.go
@@ -41,7 +41,7 @@
func TestJavaBinaryHost(t *testing.T) {
runJavaBinaryHostTestCase(t, bp2buildTestCase{
- description: "java_binary_host with srcs, exclude_srcs, jni_libs and manifest.",
+ description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
filesystem: fs,
blueprint: `java_binary_host {
name: "java-binary-host-1",
@@ -49,6 +49,7 @@
exclude_srcs: ["b.java"],
manifest: "test.mf",
jni_libs: ["jni-lib-1"],
+ javacflags: ["-Xdoclint:all/protected"],
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
@@ -57,6 +58,7 @@
"main_class": `"com.android.test.MainClass"`,
"deps": `["//other:jni-lib-1"]`,
"jvm_flags": `["-Djava.library.path=$${RUNPATH}other"]`,
+ "javacopts": `["-Xdoclint:all/protected"]`,
}),
},
})
diff --git a/java/java.go b/java/java.go
index 9b4a005..73fd9c2 100644
--- a/java/java.go
+++ b/java/java.go
@@ -24,6 +24,7 @@
"strings"
"android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -2000,6 +2001,7 @@
Deps bazel.LabelListAttribute
Main_class string
Jvm_flags bazel.StringListAttribute
+ Javacopts bazel.StringListAttribute
}
// JavaBinaryHostBp2Build is for java_binary_host bp2build.
@@ -2021,6 +2023,10 @@
Main_class: mainClass,
}
+ if m.properties.Javacflags != nil {
+ attrs.Javacopts = bazel.MakeStringListAttribute(m.properties.Javacflags)
+ }
+
// Attribute deps
deps := []string{}
if m.properties.Static_libs != nil {