Loading java/java_test.go +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import ( "os" "path/filepath" "reflect" "regexp" "sort" "strconv" "strings" Loading Loading @@ -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 { Loading java/sdk_library.go +12 −9 Original line number Diff line number Diff line Loading @@ -1295,6 +1295,8 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths { // Only provide access to the implementation library if it is actually built. if module.requiresRuntimeImplementationLibrary() { // Check any special cases for java_sdk_library. // // Only allow access to the implementation library in the following condition: Loading @@ -1306,6 +1308,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS return module.ImplementationJars() } } } return module.selectHeaderJarsForSdkVersion(ctx, sdkVersion) } Loading Loading
java/java_test.go +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import ( "os" "path/filepath" "reflect" "regexp" "sort" "strconv" "strings" Loading Loading @@ -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 { Loading
java/sdk_library.go +12 −9 Original line number Diff line number Diff line Loading @@ -1295,6 +1295,8 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths { // Only provide access to the implementation library if it is actually built. if module.requiresRuntimeImplementationLibrary() { // Check any special cases for java_sdk_library. // // Only allow access to the implementation library in the following condition: Loading @@ -1306,6 +1308,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS return module.ImplementationJars() } } } return module.selectHeaderJarsForSdkVersion(ctx, sdkVersion) } Loading