Fixed
Status Update
Comments
uc...@google.com <uc...@google.com>
gh...@google.com <gh...@google.com> #2
In LintCliClient.initializeProjects() we call project.getJavaSourceFolders() in order to find files to analyze.
In turn, project.getJavaSourceFolders() calls com.android.builder.model.SourceProvider.getJavaDirectories().
That call does *not* return the directory at src/main/kotlin, even though it is included as a source set in a Gradle build.
Hence Lint does not analyze any code under src/main/kotlin.
I'm not sure whether Lint needs to call a different method, or whether the builder model needs to return src/main/kotlin as a Java directory.
Xav, do you know the answer?
In turn, project.getJavaSourceFolders() calls com.android.builder.model.SourceProvider.getJavaDirectories().
That call does *not* return the directory at src/main/kotlin, even though it is included as a source set in a Gradle build.
Hence Lint does not analyze any code under src/main/kotlin.
I'm not sure whether Lint needs to call a different method, or whether the builder model needs to return src/main/kotlin as a Java directory.
Xav, do you know the answer?
xa...@google.com <xa...@google.com> #3
Looks like a bug in AGP, though this is weird because it means it would not work when compiling.
Jerome, please triage this. thanks!
Jerome, please triage this. thanks!
je...@google.com <je...@google.com>
am...@google.com <am...@google.com>
cm...@google.com <cm...@google.com> #4
To add some context as we discussed in person for future readers of this issue:
The root cause of this is that the kotlin android gradle plugin (KAGP) depends on the android gradle plugin (AGP) and so AGP is not aware of anything that KAGP does other than when KAGP calls apis on AGP.
The reason this works in studio is that studio also builds kotlin models to find the kotlin source sets and so lint sees both. (And in Studio the Android Plugin now depends on the Kotlin plugin)
Longer term we have plans to invert that, but for now the path of least resistance is probably reading the kotlin extension that it attaches to the AGP source sets.
The root cause of this is that the kotlin android gradle plugin (KAGP) depends on the android gradle plugin (AGP) and so AGP is not aware of anything that KAGP does other than when KAGP calls apis on AGP.
The reason this works in studio is that studio also builds kotlin models to find the kotlin source sets and so lint sees both. (And in Studio the Android Plugin now depends on the Kotlin plugin)
Longer term we have plans to invert that, but for now the path of least resistance is probably reading the kotlin extension that it attaches to the AGP source sets.
Description