summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2022-08-16 20:38:16 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-08-16 20:38:16 +0000
commit79845f9ccee3411fa7add6261ffd34d8b990b8b4 (patch)
tree01f49c9b1655416ce868eafb4403b31a193fb1be /java/lint.go
parentdae32f217410ac533f690ba8cff811f3b76b0e88 (diff)
parent62695b9f01d5c552c94c752198711e1f2a2baa5d (diff)
Merge "Collect suggested modifications from lint"
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/java/lint.go b/java/lint.go
index c27ca9821..c609a5f44 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -210,7 +210,7 @@ func lintRBEExecStrategy(ctx android.ModuleContext) string {
return ctx.Config().GetenvWithDefault("RBE_LINT_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
}
-func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.RuleBuilder) lintPaths {
+func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.RuleBuilder, srcsList android.Path) lintPaths {
projectXMLPath := android.PathForModuleOut(ctx, "lint", "project.xml")
// Lint looks for a lint.xml file next to the project.xml file, give it one.
configXMLPath := android.PathForModuleOut(ctx, "lint", "lint.xml")
@@ -241,8 +241,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru
// TODO(ccross): some of the files in l.srcs are generated sources and should be passed to
// lint separately.
- srcsList := android.PathForModuleOut(ctx, "lint-srcs.list")
- cmd.FlagWithRspFileInputList("--srcs ", srcsList, l.srcs)
+ cmd.FlagWithInput("--srcs ", srcsList)
cmd.FlagWithInput("--generated_srcs ", srcJarList)
@@ -381,7 +380,11 @@ func (l *linter) lint(ctx android.ModuleContext) {
rule.Temporary(manifest)
}
- lintPaths := l.writeLintProjectXML(ctx, rule)
+ srcsList := android.PathForModuleOut(ctx, "lint", "lint-srcs.list")
+ srcsListRsp := android.PathForModuleOut(ctx, "lint-srcs.list.rsp")
+ rule.Command().Text("cp").FlagWithRspFileInputList("", srcsListRsp, l.srcs).Output(srcsList)
+
+ lintPaths := l.writeLintProjectXML(ctx, rule, srcsList)
html := android.PathForModuleOut(ctx, "lint", "lint-report.html")
text := android.PathForModuleOut(ctx, "lint", "lint-report.txt")
@@ -441,6 +444,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
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).
Implicit(apiVersionsXMLPath)
@@ -466,6 +470,13 @@ func (l *linter) lint(ctx android.ModuleContext) {
// The HTML output contains a date, remove it to make the output deterministic.
rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html)
+ // The sources in the sandbox may have been modified by --apply-suggestions, zip them up and
+ // export them out of the sandbox.
+ rule.Command().BuiltTool("soong_zip").
+ FlagWithOutput("-o ", android.PathForModuleOut(ctx, "lint", "suggested-fixes.zip")).
+ FlagWithArg("-C ", cmd.PathForInput(android.PathForSource(ctx))).
+ FlagWithInput("-r ", srcsList)
+
rule.Build("lint", "lint")
l.outputs = lintOutputs{