diff options
author | 2021-02-25 16:23:22 +0000 | |
---|---|---|
committer | 2021-04-13 15:19:02 +0000 | |
commit | f4a88b163358de203f9346be2d04567a0acf767d (patch) | |
tree | 598bd104619a9e2fc7fe98af503e80f06e19a770 /java/lint.go | |
parent | 4f3e58c031795df55bfc764173a1e3dd3644c0eb (diff) |
Introduce NewApi lint checks
We are enabling NewApi lint check where the min sdk != compile sdk.
At the same time, we are introducing baseline files for existing
projects that fail this check in order to keep the build running.
At the very least we stop introducing new problems and teams might
realise of risks in their projects they were not aware of.
Bug: 150847901
Test: m lint-check
Change-Id: Icfa5eb98cc6b6708149f0c52fac8fc1440d9c3b0
Merged-In: Icfa5eb98cc6b6708149f0c52fac8fc1440d9c3b0
Diffstat (limited to 'java/lint.go')
-rw-r--r-- | java/lint.go | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/java/lint.go b/java/lint.go index 30843dc93..aa308e669 100644 --- a/java/lint.go +++ b/java/lint.go @@ -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) { |