Status Update
Comments
sp...@google.com <sp...@google.com>
tn...@google.com <tn...@google.com> #2
I think this would be as simple as something like this:
diff --git a/lint/libs/lint-tests/src/main/java/com/android/tools/lint/checks/infrastructure/GradleModelMocker.kt b/lint/libs/lint-tests/src/main/java/com/android/tools/lint/checks/infrastructure/GradleModelMocker.kt
index 86ceab9d69..b70ea96858 100644
--- a/lint/libs/lint-tests/src/main/java/com/android/tools/lint/checks/infrastructure/GradleModelMocker.kt
+++ b/lint/libs/lint-tests/src/main/java/com/android/tools/lint/checks/infrastructure/GradleModelMocker.kt
@@ -1050,6 +1050,9 @@ constructor(
key.startsWith("group=") -> {
updateModuleMavenName { it.copy(groupId = getUnquotedValue(key)) }
}
+ key.startsWith("version=") -> {
+ updateModuleMavenName { it.copy(version = getUnquotedValue(key)) }
+ }
key.startsWith("android.buildToolsVersion ") -> {
// Not used.
}
but I'm really unclear on the exact meanings of "group", "version" etc in build.gradle files and whether this does the right thing (and should there be an "artifact" property too?
al...@google.com <al...@google.com> #3
It's part of the Gradle project configuration. The artifact is always the project name, so there's no artifact=
.
I'm seeing the version as unspecified
in the debugger during an actual Lint run, which may be an issue with AndroidX configuring a version on the Maven Publish plugin rather than the Gradle project? Still looking into it. Even if that's broken, though, setting the version
would be a correct addition to the Gradle model mocker.
tn...@google.com <tn...@google.com> #4
Thanks. How do you set the project name for the mocker right now? (Or how are you accessing it from the lint model?)
al...@google.com <al...@google.com> #5
Through ProjectDescription
, e.g.
val provider = project()
.name("artifactId")
.type(ProjectDescription.Type.LIBRARY)
.files(
gradle(
"""
apply plugin: 'com.android.library'
group=groupId
"""
).indented(),
al...@google.com <al...@google.com> #6
This might all be moot, since it doesn't look like AndroidLintInput
handles the project version at all. That would explain why we're not seeing it at run time for projects. We do see it for prebuilt dependencies, just not the project against which lint is running:
internal fun convertToLintModelModule(): LintModelModule {
return DefaultLintModelModule(
// ...
mavenName = DefaultLintModelMavenName(
mavenGroupId.get(),
mavenArtifactId.get()
),
tn...@google.com <tn...@google.com> #7
Fixed by ag/Id3d0f361d31f9ec23ea80a2a1361b9c8f5dc576a (though it sounds like you might want to file a bug against AGP for lint inputs?)
al...@google.com <al...@google.com> #8
Yep, filed
an...@google.com <an...@google.com> #9
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Jellyfish | 2023.3.1 Canary 7
- Android Gradle Plugin 8.4.0-alpha07
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Group is specified as such: