Loading android/visibility.go +11 −0 Original line number Diff line number Diff line Loading @@ -500,6 +500,17 @@ func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) []string { // without checking the visibility rules. Here we need to add that visibility // explicitly. if rule != nil && !rule.matches(qualified) { if len(rule) == 1 { if _, ok := rule[0].(privateRule); ok { // If the rule is //visibility:private we can't append another // visibility to it. Semantically we need to convert it to a package // visibility rule for the location where the result is used, but since // modules are implicitly visible within the package we get the same // result without any rule at all, so just make it an empty list to be // appended below. rule = compositeRule{} } } rule = append(rule, packageRule{dir}) } Loading sdk/sdk_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ func TestSnapshotVisibility(t *testing.T) { "myjavalib", "mypublicjavalib", "mydefaultedjavalib", "myprivatejavalib", ], } Loading Loading @@ -140,6 +141,14 @@ func TestSnapshotVisibility(t *testing.T) { system_modules: "none", sdk_version: "none", } java_library { name: "myprivatejavalib", srcs: ["Test.java"], visibility: ["//visibility:private"], system_modules: "none", sdk_version: "none", } ` result := testSdkWithFs(t, ``, Loading Loading @@ -206,6 +215,20 @@ java_import { jars: ["java/mydefaultedjavalib.jar"], } java_import { name: "mysdk_myprivatejavalib@current", sdk_member_name: "myprivatejavalib", visibility: ["//package"], jars: ["java/myprivatejavalib.jar"], } java_import { name: "myprivatejavalib", prefer: false, visibility: ["//package"], jars: ["java/myprivatejavalib.jar"], } sdk_snapshot { name: "mysdk@current", visibility: [ Loading @@ -216,6 +239,7 @@ sdk_snapshot { "mysdk_myjavalib@current", "mysdk_mypublicjavalib@current", "mysdk_mydefaultedjavalib@current", "mysdk_myprivatejavalib@current", ], } `)) Loading Loading
android/visibility.go +11 −0 Original line number Diff line number Diff line Loading @@ -500,6 +500,17 @@ func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) []string { // without checking the visibility rules. Here we need to add that visibility // explicitly. if rule != nil && !rule.matches(qualified) { if len(rule) == 1 { if _, ok := rule[0].(privateRule); ok { // If the rule is //visibility:private we can't append another // visibility to it. Semantically we need to convert it to a package // visibility rule for the location where the result is used, but since // modules are implicitly visible within the package we get the same // result without any rule at all, so just make it an empty list to be // appended below. rule = compositeRule{} } } rule = append(rule, packageRule{dir}) } Loading
sdk/sdk_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ func TestSnapshotVisibility(t *testing.T) { "myjavalib", "mypublicjavalib", "mydefaultedjavalib", "myprivatejavalib", ], } Loading Loading @@ -140,6 +141,14 @@ func TestSnapshotVisibility(t *testing.T) { system_modules: "none", sdk_version: "none", } java_library { name: "myprivatejavalib", srcs: ["Test.java"], visibility: ["//visibility:private"], system_modules: "none", sdk_version: "none", } ` result := testSdkWithFs(t, ``, Loading Loading @@ -206,6 +215,20 @@ java_import { jars: ["java/mydefaultedjavalib.jar"], } java_import { name: "mysdk_myprivatejavalib@current", sdk_member_name: "myprivatejavalib", visibility: ["//package"], jars: ["java/myprivatejavalib.jar"], } java_import { name: "myprivatejavalib", prefer: false, visibility: ["//package"], jars: ["java/myprivatejavalib.jar"], } sdk_snapshot { name: "mysdk@current", visibility: [ Loading @@ -216,6 +239,7 @@ sdk_snapshot { "mysdk_myjavalib@current", "mysdk_mypublicjavalib@current", "mysdk_mydefaultedjavalib@current", "mysdk_myprivatejavalib@current", ], } `)) Loading