diff options
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 26 |
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 { |