diff options
author | Colin Cross <ccross@android.com> | 2020-06-02 20:09:13 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2020-06-18 11:01:47 -0700 |
commit | 1e28e3c61593571db5ecea328d134ee50501104d (patch) | |
tree | 4b9c9ed511078db6f9516e47618cce021c56be28 /java/java.go | |
parent | 1c14b4ecf632f0b90b66b086df03f8eb4c6a33b0 (diff) |
Add support for running Android lint on java and android modules.
Add a rule that runs Android lint on each java and android module
and produces reports in xml, html and text formats.
Bug: 153485543
Test: m out/soong/.intermediates/packages/apps/Settings/Settings-core/android_common/lint-report.html
Change-Id: I5a530975b73ba767fef45b257d4f9ec901a19fcb
Merged-In: I5a530975b73ba767fef45b257d4f9ec901a19fcb
(cherry picked from commit 014489c1e6cbd2801970b88d5b608dc5c45b403c)
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index c80eef97f..0c0c659e9 100644 --- a/java/java.go +++ b/java/java.go @@ -475,6 +475,7 @@ type Module struct { hiddenAPI dexpreopter + linter // list of the xref extraction files kytheFiles android.Paths @@ -494,6 +495,7 @@ func (j *Module) addHostAndDeviceProperties() { j.AddProperties( &j.deviceProperties, &j.dexpreoptProperties, + &j.linter.properties, ) } @@ -1635,6 +1637,28 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { outputFile = implementationAndResourcesJar } + if ctx.Device() { + lintSDKVersionString := func(sdkSpec sdkSpec) string { + if v := sdkSpec.version; v.isNumbered() { + return v.String() + } else { + return ctx.Config().DefaultAppTargetSdk() + } + } + + j.linter.name = ctx.ModuleName() + j.linter.srcs = srcFiles + j.linter.srcJars = srcJars + j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...) + j.linter.classes = j.implementationJarFile + j.linter.minSdkVersion = lintSDKVersionString(j.minSdkVersion()) + j.linter.targetSdkVersion = lintSDKVersionString(j.targetSdkVersion()) + j.linter.compileSdkVersion = lintSDKVersionString(j.sdkVersion()) + j.linter.javaLanguageLevel = flags.javaVersion.String() + j.linter.kotlinLanguageLevel = "1.3" + j.linter.lint(ctx) + } + ctx.CheckbuildFile(outputFile) // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource @@ -2235,6 +2259,7 @@ func TestFactory() android.Module { module.Module.properties.Installable = proptools.BoolPtr(true) module.Module.dexpreopter.isTest = true + module.Module.linter.test = true InitJavaModule(module, android.HostAndDeviceSupported) return module @@ -2249,6 +2274,7 @@ func TestHelperLibraryFactory() android.Module { module.Module.properties.Installable = proptools.BoolPtr(true) module.Module.dexpreopter.isTest = true + module.Module.linter.test = true InitJavaModule(module, android.HostAndDeviceSupported) return module @@ -2823,6 +2849,7 @@ func DefaultsFactory() android.Module { &DexImportProperties{}, &android.ApexProperties{}, &RuntimeResourceOverlayProperties{}, + &LintProperties{}, ) android.InitDefaultsModule(module) |