java/lint: enable lint on non-generated srcjar

Soong made the assumption that any .srcjar was generated source, for
which the lints were not executed. It may not be the case for .srcjar
that are manually created. Run the linter on any .srcjar that has been
provided within the src attribute, but ignore any source generated
.srcjar (such as .proto or .aidl).

Test: m lint-check
Bug: 228774926
Change-Id: If214fb57f54049fce54297ee6bf65d734b3d2e6d
This commit is contained in:
Thiébaud Weksteen
2022-05-05 14:49:02 +10:00
parent be9b9deef9
commit 5c26f8185a

View File

@@ -1019,6 +1019,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
ctx.PropertyErrorf("common_srcs", "common_srcs must be .kt files")
}
nonGeneratedSrcJars := srcFiles.FilterByExt(".srcjar")
srcFiles = j.genSources(ctx, srcFiles, flags)
// Collect javac flags only after computing the full set of srcFiles to
@@ -1490,8 +1491,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
j.linter.name = ctx.ModuleName()
j.linter.srcs = srcFiles
j.linter.srcJars = srcJars
j.linter.srcs = append(srcFiles, nonGeneratedSrcJars...)
j.linter.srcJars, _ = android.FilterPathList(srcJars, nonGeneratedSrcJars)
j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...)
j.linter.classes = j.implementationJarFile
j.linter.minSdkVersion = lintSDKVersionString(j.MinSdkVersion(ctx))