summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author mattgilbride <mattgilbride@google.com> 2023-03-22 17:44:18 +0000
committer mattgilbride <mattgilbride@google.com> 2023-03-22 17:52:56 +0000
commitb597abdeb12fb07d985f3e98171d1d470940afa6 (patch)
tree4bf7331dbbe55f1440315bf57eb3262456c7e5d3 /java/lint.go
parentff8c95b6102f961606bec9676a5a46bcfe20b570 (diff)
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
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go5
1 files changed, 4 insertions, 1 deletions
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)
}