java libs that isn't installable is gracefully rejected
... rather than causing soong panic.
Bug: 146197571
Test: m (apex_test amended)
Change-Id: I3679a4e3041527533c1c05d54f3aa514abd6095b
diff --git a/apex/apex.go b/apex/apex.go
index be86d80..0aaba91 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -472,7 +472,7 @@
}
func (af *apexFile) Ok() bool {
- return af.builtFile != nil || af.builtFile.String() == ""
+ return af.builtFile != nil && af.builtFile.String() != ""
}
type apexBundle struct {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 3aa72e3..578bd66 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3055,6 +3055,29 @@
ensureContains(t, args["opt_flags"], "--manifest_json "+module.Output("apex_manifest.json").Output.String())
}
+func TestRejectNonInstallableJavaLibrary(t *testing.T) {
+ testApexError(t, `"myjar" is not configured to be compiled into dex`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjar"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_library {
+ name: "myjar",
+ srcs: ["foo/bar/MyClass.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+}
+
func TestMain(m *testing.M) {
run := func() int {
setUp()