Support dist_group property instead of owner for setting sdk dist subdirectory
Reusing the owner property is confusing, especially when the property is
required on every java_sdk_library module. Create a new dist_group property
to use instead.
Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I9e62c703a95d6b63cafa60bffb1b37ba85388593
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 8f36758..ecf2b1a 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -457,6 +457,11 @@
// * API incompatibilities baseline filegroup -> <dist-stem>-incompatibilities.api.<scope>.latest
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
+ // in the public Android SDK.
+ Dist_group *string
+
// A compatibility mode that allows historical API-tracking files to not exist.
// Do not use.
Unsafe_ignore_missing_latest_api bool
@@ -1198,12 +1203,10 @@
// The dist path of the stub artifacts
func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string {
- if module.ModuleBase.Owner() != "" {
- return path.Join("apistubs", module.ModuleBase.Owner(), apiScope.name)
- } else if Bool(module.sdkLibraryProperties.Core_lib) {
+ if Bool(module.sdkLibraryProperties.Core_lib) {
return path.Join("apistubs", "core", apiScope.name)
} else {
- return path.Join("apistubs", "android", apiScope.name)
+ return path.Join("apistubs", module.distGroup(), apiScope.name)
}
}
@@ -1228,6 +1231,19 @@
return proptools.StringDefault(module.sdkLibraryProperties.Dist_stem, module.BaseModuleName())
}
+// 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"
+}
+
func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string {
return ":" + module.distStem() + ".api." + apiScope.name + ".latest"
}