diff options
author | 2021-02-18 15:53:13 +0000 | |
---|---|---|
committer | 2021-02-18 15:53:13 +0000 | |
commit | 8a75058d3f6ebe0d696f48f2f28369d60697637c (patch) | |
tree | cdcd579904a4bc601748215f550e3174786f986b /java/lint.go | |
parent | ca52bfcf0fb0459884b597ab166e43be8335785b (diff) | |
parent | 5d190cc24e73913c5dd05b270317f31a32c4593a (diff) |
Merge "Add support for lint baseline files"
Diffstat (limited to 'java/lint.go')
-rw-r--r-- | java/lint.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/java/lint.go b/java/lint.go index c9e0cdd2f..827259573 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 } } @@ -344,6 +349,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()) |