Merge "Introduce NewApi lint checks" am: 53d69eb028 am: 4a77ab744d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1675510

Change-Id: Iff91bd3211debb0058541fcd01182d10994f695d
This commit is contained in:
Pedro Loureiro 2021-04-15 12:27:01 +00:00 committed by Automerger Merge Worker
commit f0ff1d5243
2 changed files with 32 additions and 18 deletions

View file

@ -1261,6 +1261,14 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) {
if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline mybaseline.xml") {
t.Error("did not use the correct file for baseline")
}
if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") {
t.Error("should check NewApi errors")
}
if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") {
t.Error("should combine NewApi errors with SomeCheck errors")
}
}
func TestGeneratedSources(t *testing.T) {

View file

@ -57,24 +57,25 @@ type LintProperties struct {
}
type linter struct {
name string
manifest android.Path
mergedManifest android.Path
srcs android.Paths
srcJars android.Paths
resources android.Paths
classpath android.Paths
classes android.Path
extraLintCheckJars android.Paths
test bool
library bool
minSdkVersion string
targetSdkVersion string
compileSdkVersion string
javaLanguageLevel string
kotlinLanguageLevel string
outputs lintOutputs
properties LintProperties
name string
manifest android.Path
mergedManifest android.Path
srcs android.Paths
srcJars android.Paths
resources android.Paths
classpath android.Paths
classes android.Path
extraLintCheckJars android.Paths
test bool
library bool
minSdkVersion string
targetSdkVersion string
compileSdkVersion string
javaLanguageLevel string
kotlinLanguageLevel string
outputs lintOutputs
properties LintProperties
extraMainlineLintErrors []string
reports android.Paths
@ -246,6 +247,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru
cmd.FlagWithInput("@",
android.PathForSource(ctx, "build/soong/java/lint_defaults.txt"))
cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks)
cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks)
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
@ -282,6 +284,10 @@ func (l *linter) lint(ctx android.ModuleContext) {
return
}
if l.minSdkVersion != l.compileSdkVersion {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, "NewApi")
}
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
for _, extraLintCheckModule := range extraLintCheckModules {
if ctx.OtherModuleHasProvider(extraLintCheckModule, JavaInfoProvider) {