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. // a list of top-level directories containing Java stub files to merge show/hide annotations from.
Merge_inclusion_annotations_dirs []string 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. // If set to true then don't create dist rules.
No_dist *bool No_dist *bool
@@ -458,7 +455,7 @@ type sdkLibraryProperties struct {
Dist_stem *string Dist_stem *string
// The subdirectory for the artifacts that are copied to the dist directory. If not specified // 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. // in the public Android SDK.
Dist_group *string Dist_group *string
@@ -1203,11 +1200,7 @@ func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
// The dist path of the stub artifacts // The dist path of the stub artifacts
func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string { func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string {
if Bool(module.sdkLibraryProperties.Core_lib) { return path.Join("apistubs", module.distGroup(), apiScope.name)
return path.Join("apistubs", "core", apiScope.name)
} else {
return path.Join("apistubs", module.distGroup(), apiScope.name)
}
} }
// Get the sdk version for use when compiling the stubs library. // 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. // distGroup returns the subdirectory of the dist path of the stub artifacts.
func (module *SdkLibrary) distGroup() string { func (module *SdkLibrary) distGroup() string {
if group := proptools.String(module.sdkLibraryProperties.Dist_group); group != "" { return proptools.StringDefault(module.sdkLibraryProperties.Dist_group, "unknown")
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"
} }
func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string { func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string {

View File

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