Merge changes I162b0f68,I1689b670,Id6d997ee,I9aae2a16

* changes:
  Don't use unsafe_ignore_missing_latest_api in TestJavaSdkLibraryDist
  Remove core_lib property from java_sdk_library
  Ignore owner property when computing java_sdk_library dist subdirectory
  Make the default java_sdk_library dist_group "unknown"
This commit is contained in:
Colin Cross
2021-06-08 17:02:59 +00:00
committed by Gerrit Code Review
2 changed files with 15 additions and 40 deletions

View File

@@ -435,9 +435,6 @@ type sdkLibraryProperties struct {
// a list of top-level directories containing Java stub files to merge show/hide annotations from.
Merge_inclusion_annotations_dirs []string
// If set to true, the path of dist files is apistubs/core. Defaults to false.
Core_lib *bool
// If set to true then don't create dist rules.
No_dist *bool
@@ -458,7 +455,7 @@ type sdkLibraryProperties struct {
Dist_stem *string
// The subdirectory for the artifacts that are copied to the dist directory. If not specified
// then defaults to "android". Should be set to "android" for anything that should be published
// then defaults to "unknown". Should be set to "android" for anything that should be published
// in the public Android SDK.
Dist_group *string
@@ -1203,11 +1200,7 @@ func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
// The dist path of the stub artifacts
func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string {
if Bool(module.sdkLibraryProperties.Core_lib) {
return path.Join("apistubs", "core", apiScope.name)
} else {
return path.Join("apistubs", module.distGroup(), apiScope.name)
}
return path.Join("apistubs", module.distGroup(), apiScope.name)
}
// Get the sdk version for use when compiling the stubs library.
@@ -1233,15 +1226,7 @@ func (module *SdkLibrary) distStem() string {
// distGroup returns the subdirectory of the dist path of the stub artifacts.
func (module *SdkLibrary) distGroup() string {
if group := proptools.String(module.sdkLibraryProperties.Dist_group); group != "" {
return group
}
// TODO(b/186723288): Remove this once everything uses dist_group.
if owner := module.ModuleBase.Owner(); owner != "" {
return owner
}
// TODO(b/186723288): Make this "unknown".
return "android"
return proptools.StringDefault(module.sdkLibraryProperties.Dist_group, "unknown")
}
func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string {

View File

@@ -844,40 +844,34 @@ func TestJavaSdkLibraryDist(t *testing.T) {
PrepareForTestWithJavaBuildComponents,
PrepareForTestWithJavaDefaultModules,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis(
"sdklib_no_group",
"sdklib_group_foo",
"sdklib_owner_foo",
"foo"),
).RunTestWithBp(t, `
java_sdk_library {
name: "sdklib_no_owner",
unsafe_ignore_missing_latest_api: true,
name: "sdklib_no_group",
srcs: ["foo.java"],
}
java_sdk_library {
name: "sdklib_group_foo",
unsafe_ignore_missing_latest_api: true,
srcs: ["foo.java"],
dist_group: "foo",
}
java_sdk_library {
name: "sdklib_owner_foo",
unsafe_ignore_missing_latest_api: true,
srcs: ["foo.java"],
owner: "foo",
}
java_sdk_library {
name: "sdklib_stem_foo",
unsafe_ignore_missing_latest_api: true,
srcs: ["foo.java"],
dist_stem: "foo",
}
java_sdk_library {
name: "sdklib_core_lib",
unsafe_ignore_missing_latest_api: true,
srcs: ["foo.java"],
core_lib: true,
}
`)
type testCase struct {
@@ -887,9 +881,9 @@ func TestJavaSdkLibraryDist(t *testing.T) {
}
testCases := []testCase{
{
module: "sdklib_no_owner",
distDir: "apistubs/android/public",
distStem: "sdklib_no_owner.jar",
module: "sdklib_no_group",
distDir: "apistubs/unknown/public",
distStem: "sdklib_no_group.jar",
},
{
module: "sdklib_group_foo",
@@ -897,20 +891,16 @@ func TestJavaSdkLibraryDist(t *testing.T) {
distStem: "sdklib_group_foo.jar",
},
{
// Owner doesn't affect distDir after b/186723288.
module: "sdklib_owner_foo",
distDir: "apistubs/foo/public",
distDir: "apistubs/unknown/public",
distStem: "sdklib_owner_foo.jar",
},
{
module: "sdklib_stem_foo",
distDir: "apistubs/android/public",
distDir: "apistubs/unknown/public",
distStem: "foo.jar",
},
{
module: "sdklib_core_lib",
distDir: "apistubs/core/public",
distStem: "sdklib_core_lib.jar",
},
}
for _, tt := range testCases {