summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Pedro Loureiro <pedroql@google.com> 2021-02-15 15:41:33 +0000
committer Pedro Loureiro <pedroql@google.com> 2021-02-18 11:15:30 +0000
commit5d190cc24e73913c5dd05b270317f31a32c4593a (patch)
treec7494a7871181997e7df45e02c66f1a6f4814e09 /java/lint.go
parentc66769ddd96b88cb129733e03b585b0d9c3bed15 (diff)
Add support for lint baseline files
Test: m droid Test: go test ^TestJavaLint # (from soong/build/java) Change-Id: I249a0a0597b0bf8495460ed283b476ad2eb36edc
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/lint.go b/java/lint.go
index cd2a904d6..a42deecdf 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -19,6 +19,8 @@ import (
"sort"
"strings"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
)
@@ -46,6 +48,9 @@ type LintProperties struct {
// Modules that provide extra lint checks
Extra_check_modules []string
+
+ // Name of the file that lint uses as the baseline. Defaults to "lint-baseline.xml".
+ Baseline_filename *string
}
}
@@ -343,6 +348,19 @@ func (l *linter) lint(ctx android.ModuleContext) {
cmd.FlagWithArg("--check ", checkOnly)
}
+ if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" {
+ var lintBaseline android.OptionalPath
+ if String(l.properties.Lint.Baseline_filename) != "" {
+ // if manually specified, we require the file to exist
+ lintBaseline = android.OptionalPathForPath(android.PathForModuleSrc(ctx, lintFilename))
+ } else {
+ lintBaseline = android.ExistentPathForSource(ctx, ctx.ModuleDir(), lintFilename)
+ }
+ if lintBaseline.Valid() {
+ cmd.FlagWithInput("--baseline ", lintBaseline.Path())
+ }
+ }
+
cmd.Text("|| (").Text("cat").Input(text).Text("; exit 7)").Text(")")
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())