From b597abdeb12fb07d985f3e98171d1d470940afa6 Mon Sep 17 00:00:00 2001 From: mattgilbride Date: Wed, 22 Mar 2023 17:44:18 +0000 Subject: [PATCH] Android Lint: allow local override of --exitcode flag The --exitcode flag tells lint to exit with an error code if any incidents at ERROR level or above are found. Unfortunately, that means an invocation of lint against the entire tree will fail with whichever module fails first. This covers up any other failures and makes updating lint in AOSP more cumbersome. This change allows one to set `ANDROID_LINT_SUPPRESS_EXIT_CODE=true` to modify this behavior and collect full lint results even if there are errors in some modules. Bug: 274780888 Test: Tested manually by changing code to trigger lint errors, and settig/unsetting this flag. Change-Id: I71ab89c9bffafe6eb83171102c2c253171450266 --- java/lint.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/lint.go b/java/lint.go index 58b43dfdb..40ef48416 100644 --- a/java/lint.go +++ b/java/lint.go @@ -496,7 +496,6 @@ func (l *linter) lint(ctx android.ModuleContext) { FlagWithArg("--java-language-level ", l.javaLanguageLevel). FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel). FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())). - Flag("--exitcode"). Flag("--apply-suggestions"). // applies suggested fixes to files in the sandbox Flags(l.properties.Lint.Flags). Implicit(annotationsZipPath). @@ -505,6 +504,10 @@ func (l *linter) lint(ctx android.ModuleContext) { rule.Temporary(lintPaths.projectXML) rule.Temporary(lintPaths.configXML) + if exitCode := ctx.Config().Getenv("ANDROID_LINT_SUPPRESS_EXIT_CODE"); exitCode == "" { + cmd.Flag("--exitcode") + } + if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" { cmd.FlagWithArg("--check ", checkOnly) }