From baf34783a43af264fe3c2301a690c9a434a2549b Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 28 May 2024 17:27:22 +0100 Subject: [PATCH] Update build to handle documentation issues being errors Previously, documentation issues had `lint` severity (which was between `warning` and `hide`) by default. However, a recent change in Metalava switched documentation issues to `error`. That broke some `droidstubs` modules that either did not specify `api_lint` or were previously allow listed to not use `--lints-as-errors`. This change adds `--error-when-new-category Documentation` to the Metalava arguments on any use of `droidstubs` that did not previously specify `--lints-as-errors` to prevent the build breakage while still warning developers of the problem and preventing new cases being added. Bug: 343157584 Test: ./gradlew Change-Id: Id80bc05e2dade580b2f3ac6416aeeed6b64ba22a --- java/droidstubs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index ca81343f0..b94ad1669 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -993,6 +993,7 @@ func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCo func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, doApiLint bool, doCheckReleased bool) { // Add API lint options. + treatDocumentationIssuesAsErrors := false if doApiLint { var newSince android.Paths if d.properties.Check_api.Api_lint.New_since != nil { @@ -1006,7 +1007,7 @@ func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *andro // TODO(b/154317059): Clean up this allowlist by baselining and/or checking in last-released. if d.Name() != "android.car-system-stubs-docs" && d.Name() != "android.car-stubs-docs" { - cmd.Flag("--lints-as-errors") + treatDocumentationIssuesAsErrors = true cmd.Flag("--warnings-as-errors") // Most lints are actually warnings. } @@ -1052,6 +1053,11 @@ func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *andro cmd.FlagWithArg("--error-message:api-lint ", msg) } + if !treatDocumentationIssuesAsErrors { + // Treat documentation issues as warnings, but error when new. + cmd.Flag("--error-when-new-category").Flag("Documentation") + } + // Add "check released" options. (Detect incompatible API changes from the last public release) if doCheckReleased { baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Last_released.Baseline_file)