diff --git a/java/lint.go b/java/lint.go index fac9a1983..ca87dbab6 100644 --- a/java/lint.go +++ b/java/lint.go @@ -88,7 +88,7 @@ func (l *linter) deps(ctx android.BottomUpMutatorContext) { } func (l *linter) writeLintProjectXML(ctx android.ModuleContext, - rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) { + rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir, homeDir android.WritablePath, deps android.Paths) { var resourcesList android.WritablePath if len(l.resources) > 0 { @@ -106,6 +106,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, // Lint looks for a lint.xml file next to the project.xml file, give it one. configXMLPath = android.PathForModuleOut(ctx, "lint", "lint.xml") cacheDir = android.PathForModuleOut(ctx, "lint", "cache") + homeDir = android.PathForModuleOut(ctx, "lint", "home") srcJarDir := android.PathForModuleOut(ctx, "lint-srcjars") srcJarList := zipSyncCmd(ctx, rule, srcJarDir, l.srcJars) @@ -165,7 +166,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) - return projectXMLPath, configXMLPath, cacheDir, deps + return projectXMLPath, configXMLPath, cacheDir, homeDir, deps } // generateManifest adds a command to the rule to write a dummy manifest cat contains the @@ -207,18 +208,19 @@ func (l *linter) lint(ctx android.ModuleContext) { l.manifest = manifest } - projectXML, lintXML, cacheDir, deps := l.writeLintProjectXML(ctx, rule) + projectXML, lintXML, cacheDir, homeDir, deps := l.writeLintProjectXML(ctx, rule) l.outputs.html = android.PathForModuleOut(ctx, "lint-report.html") l.outputs.text = android.PathForModuleOut(ctx, "lint-report.txt") l.outputs.xml = android.PathForModuleOut(ctx, "lint-report.xml") - rule.Command().Text("rm -rf").Flag(cacheDir.String()) - rule.Command().Text("mkdir -p").Flag(cacheDir.String()) + rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String()) + rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String()) rule.Command(). Text("("). Flag("JAVA_OPTS=-Xmx2048m"). + FlagWithArg("ANDROID_SDK_HOME=", homeDir.String()). FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath(ctx)). FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXmlPath(ctx)). Tool(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/bin/lint")). @@ -239,7 +241,7 @@ func (l *linter) lint(ctx android.ModuleContext) { Text("|| (").Text("cat").Input(l.outputs.text).Text("; exit 7)"). Text(")") - rule.Command().Text("rm -rf").Flag(cacheDir.String()) + rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String()) rule.Build(pctx, ctx, "lint", "lint") }