java_sdk_library: Propagate naming_scheme to snapshot

Bug: 155164730
Test: m nothing
Change-Id: Iec7c52d2102b6294540090f3c1e32bd9d8cc7da8
This commit is contained in:
Paul Duffin 2020-05-13 16:54:55 +01:00
parent 38b5785e3f
commit f7a6433bab
2 changed files with 75 additions and 0 deletions

View file

@ -1668,6 +1668,9 @@ type sdkLibrarySdkMemberProperties struct {
// The Java stubs source files.
Stub_srcs []string
// The naming scheme.
Naming_scheme *string
}
type scopeProperties struct {
@ -1697,9 +1700,14 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
}
s.Libs = sdk.properties.Libs
s.Naming_scheme = sdk.commonProperties.Naming_scheme
}
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
if s.Naming_scheme != nil {
propertySet.AddProperty("naming_scheme", proptools.String(s.Naming_scheme))
}
for _, apiScope := range allApiScopes {
if properties, ok := s.Scopes[apiScope]; ok {
scopeSet := propertySet.AddPropertySet(apiScope.name)

View file

@ -1386,3 +1386,70 @@ sdk_snapshot {
),
)
}
func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) {
result := testSdkWithJava(t, `
sdk {
name: "mysdk",
java_sdk_libs: ["myjavalib"],
}
java_sdk_library {
name: "myjavalib",
apex_available: ["//apex_available:anyapex"],
srcs: ["Test.java"],
sdk_version: "current",
naming_scheme: "framework-modules",
public: {
enabled: true,
},
}
`)
result.CheckSnapshot("mysdk", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
apex_available: ["//apex_available:anyapex"],
naming_scheme: "framework-modules",
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
}
java_sdk_library_import {
name: "myjavalib",
prefer: false,
apex_available: ["//apex_available:anyapex"],
naming_scheme: "framework-modules",
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
}
sdk_snapshot {
name: "mysdk@current",
java_sdk_libs: ["mysdk_myjavalib@current"],
}
`),
checkAllCopyRules(`
.intermediates/myjavalib-stubs-publicapi/android_common/javac/myjavalib-stubs-publicapi.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib-stubs-srcs-publicapi/android_common/myjavalib-stubs-srcs-publicapi_api.txt -> sdk_library/public/myjavalib.txt
.intermediates/myjavalib-stubs-srcs-publicapi/android_common/myjavalib-stubs-srcs-publicapi_api.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
),
)
}