From c540beef74e30cf30a4a1cc3f250b2ddbe45ad42 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 29 Aug 2024 15:35:58 +0100 Subject: [PATCH] Retry: Allow modules to override --error-when-new UnflaggedApi Some `java_sdk_library` and `droidstubs` modules already specify `--error UnflaggedApi` but they are currently ignored because they are added before the `--error-when-new UnflaggedApi` automatically added by Soong and Metalava uses the last setting. That means adding `--error-when-new UnflaggedApi` in change https://r.android.com/3248013 actually reduced the severity of the issue for those modules making it more likely that they would be missed. This change only adds the `--error-when-new UnflaggedApi` if it does not already appear in the metalava command. Bug: 361582214 Test: m checkapi Change-Id: I7228bf9794b1c7e27d7acf7a461956b30f3335f5 --- java/droidstubs.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index 137ec9254..6bcdf85a2 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -970,10 +970,14 @@ func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *andro d.apiLintReport = android.PathForModuleOut(ctx, Everything.String(), "api_lint_report.txt") cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint" - // Make sure that existing UnflaggedApi issues are reported as warnings but issues in - // new/changed code are treated as errors by the Build Warnings Aye Aye Analyzer in Gerrit. + // If UnflaggedApi issues have not already been configured then make sure that existing + // UnflaggedApi issues are reported as warnings but issues in new/changed code are treated as + // errors by the Build Warnings Aye Aye Analyzer in Gerrit. // Once existing issues have been fixed this will be changed to error. - cmd.Flag("--error-when-new UnflaggedApi") + // TODO(b/362771529): Switch to --error + if !strings.Contains(cmd.String(), " UnflaggedApi ") { + cmd.Flag("--error-when-new UnflaggedApi") + } // TODO(b/154317059): Clean up this allowlist by baselining and/or checking in last-released. if d.Name() != "android.car-system-stubs-docs" &&