summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2020-05-26 18:13:57 +0100
committerPaul Duffin <paulduffin@google.com>2020-05-26 18:32:44 +0100
commitdaaa332827b6730ec0af4fd359fbbb4daae714ad (patch)
tree5f9356d53d978f5a8af562d7bb963ef8dfddaac5 /java/java_test.go
parent62bd3c7b476b9d4bc2667521c807592e4a8af278 (diff)
java_sdk_library: Only expose impl jars when they are built
The implementation jars are not built if api_only: true. In that case the jar paths must not be exposed implicitly as they will be nil and they will just be ignored. This change ensures that stubs are returned when the implementation jars are not built. Bug: 155164730 Test: m droid Change-Id: Ic495982a5dcb2754916260e7d91d921a5da288ae
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index ab6d88ed6..e03e57b78 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -19,6 +19,7 @@ import (
"os"
"path/filepath"
"reflect"
+ "regexp"
"sort"
"strconv"
"strings"
@@ -1261,6 +1262,31 @@ func TestJavaSdkLibrary(t *testing.T) {
}
}
+func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
+ ctx, _ := testJava(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ api_only: true,
+ public: {
+ enabled: true,
+ },
+ }
+
+ java_library {
+ name: "bar",
+ srcs: ["b.java"],
+ libs: ["foo"],
+ }
+ `)
+
+ // The bar library should depend on the stubs jar.
+ barLibrary := ctx.ModuleForTests("bar", "android_common").Rule("javac")
+ if expected, actual := `^-classpath .*:/[^:]*/turbine-combined/foo\.stubs\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
+ t.Errorf("expected %q, found %#q", expected, actual)
+ }
+}
+
func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
testJava(t, `
java_sdk_library {