diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go index c91b32117..722c721d5 100644 --- a/java/prebuilt_apis.go +++ b/java/prebuilt_apis.go @@ -248,9 +248,9 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) { } // Create incompatibilities tracking files for all modules, if we have a "next" api. + incompatibilities := make(map[string]bool) if nextApiDir := String(p.properties.Next_api_dir); nextApiDir != "" { files := getPrebuiltFilesInSubdir(mctx, nextApiDir, "api/*incompatibilities.txt") - incompatibilities := make(map[string]bool) for _, f := range files { localPath := strings.TrimPrefix(f, mydir) module, _, scope := parseApiFilePath(mctx, localPath) @@ -266,11 +266,11 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) { incompatibilities[referencedModule+"."+scope] = true } - // Create empty incompatibilities files for remaining modules - for _, k := range android.SortedStringKeys(m) { - if _, ok := incompatibilities[k]; !ok { - createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest")) - } + } + // Create empty incompatibilities files for remaining modules + for _, k := range android.SortedStringKeys(m) { + if _, ok := incompatibilities[k]; !ok { + createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest")) } } } diff --git a/java/sdk_library.go b/java/sdk_library.go index 30d120d5c..b03f90cf4 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -452,6 +452,7 @@ type sdkLibraryProperties struct { // that references the latest released API and remove API specification files. // * API specification filegroup -> .api..latest // * Removed API specification filegroup -> -removed.api..latest + // * API incompatibilities baseline filegroup -> -incompatibilities.api..latest Dist_stem *string // A compatibility mode that allows historical API-tracking files to not exist. @@ -1059,6 +1060,9 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { if m := android.SrcIsModule(module.latestRemovedApiFilegroupName(apiScope)); !ctx.OtherModuleExists(m) { missingApiModules = append(missingApiModules, m) } + if m := android.SrcIsModule(module.latestIncompatibilitiesFilegroupName(apiScope)); !ctx.OtherModuleExists(m) { + missingApiModules = append(missingApiModules, m) + } } if len(missingApiModules) != 0 && !module.sdkLibraryProperties.Unsafe_ignore_missing_latest_api { m := module.Name() + " is missing tracking files for previously released library versions.\n" @@ -1165,6 +1169,10 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri return ":" + module.distStem() + "-removed.api." + apiScope.name + ".latest" } +func (module *SdkLibrary) latestIncompatibilitiesFilegroupName(apiScope *apiScope) string { + return ":" + module.distStem() + "-incompatibilities.api." + apiScope.name + ".latest" +} + func childModuleVisibility(childVisibility []string) []string { if childVisibility == nil { // No child visibility set. The child will use the visibility of the sdk_library. @@ -1389,6 +1397,8 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC props.Check_api.Last_released.Api_file = latestApiFilegroupName props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( module.latestRemovedApiFilegroupName(apiScope)) + props.Check_api.Last_released.Baseline_file = proptools.StringPtr( + module.latestIncompatibilitiesFilegroupName(apiScope)) if proptools.Bool(module.sdkLibraryProperties.Api_lint.Enabled) { // Enable api lint.