What gradle task to build our custom checks lint jar?

387 views
Skip to first unread message

colto...@protonmail.com

unread,
Jun 5, 2021, 10:34:12 PM6/5/21
to lint-dev
At Android Dev Summit, Matthew Gharrity presented on lint and showed that if you "make project" the custom lint checks in your project are built and therefore show up in your ide if you app relies on them. I filed a bug here https://issuetracker.google.com/issues/189593701

The fact that these custom lint checks aren't applied to all of my teams local machines is a killer for our productivity because we don't run lint on every PR and instead only run it nightly.

One idea I had is to make the gradle "clean" task depend on the lint build task, but I don't know what that task is. Does anyone know how to get the customLintModule to build via gradle? I've had luck running `app:lint` but that runs lint for my entire project and it takes a very long time, so I want to just build the custom lint module so that it shows on all of my teams machines during local development.

Tor Norbye

unread,
Jul 14, 2021, 8:25:36 PM7/14/21
to lint-dev
I don't know what the task is exactly but if you run 
   ./gradlew --info :app:lint
it will list all the tasks it's running which will hopefully make it jump out. For the android lint rules project which uses lintPublish, not lintChecks, to create an AAR, it looks like the task is
:library:prepareLintJarForPublish
(and :library:bundleDebugLocalLintAar to create the .aar file containing it).

-- Tor

colto...@protonmail.com

unread,
Jul 31, 2021, 11:20:09 PM7/31/21
to lint-dev
Thanks Tor. For me running --info didn't really end up working (too many tasks to try to figure out) so I just went to my customlint module itself and started trying all of the tasks there. Unsurprisingly... the winner was ./gradlew customlintmodule:jar =)

Now I just run that task and all custom lint checks work in the IDE. Thank you!

As an aside... after running that command, I noticed this all over. Should I be worried about this msg "does not contain a valid registry manifest key (Lint-Registry-v2)."?
```
  Input property 'variantInputs.androidTestArtifact.artifactCollectionsInputs.compileClasspath.allFileCollection' file /Users/coltonidle/Dev/rollertoaster/mysubmodule/build/intermediates/full_jar/debug/full.jar has changed.
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.org-jetbrains/uast/30.1.0-alpha05/c90ba78f46bae1b285b7af54f6d76a1c16d0f23e/uast-30.1.0-alpha05.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20181211/216c2e14b070f334479d800987affe4054cd563f/trove4j-1.0.20181211.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.com-intellij/intellij-core/30.1.0-alpha05/9dd0159537087de0a9819ee76e6a2f96907511f9/intellij-core-30.1.0-alpha05.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.10/3f4af7aff21c4ec46e3cdd645639d0a63a68d3d0/kotlin-stdlib-jdk8-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
```

Tor Norbye

unread,
Aug 2, 2021, 11:17:02 AM8/2/21
to lint-dev
No, you can ignore those warnings. Are you still seeing those in a new version of lint? I vaguely remember fixing it -- though maybe I just tracked down the cause but haven't checked in a fix yet? Basically what happened is that lint's jar loader had a check to make sure that it could actually extract an issue registry for a jar file that it's handed (that's the message you're seeing here).  At some semi-recent point, Gradle started passing additional jars as the lint jar path (including not just lint jar but its dependencies as well, such as the Kotlin standard library) and this is what generates these warnings -- they're benign, since lint will just resume. 

-- Tor

colto...@protonmail.com

unread,
Aug 2, 2021, 5:27:04 PM8/2/21
to lint-dev
Yep. This is a recent version of lint!

val lintVersion = "30.1.0-alpha05"

Do you want me to file a bug on issue tracker?

Tor Norbye

unread,
Aug 2, 2021, 5:29:03 PM8/2/21
to colto...@protonmail.com, lint-dev
Yes, that would be great, thanks!

--
You received this message because you are subscribed to the Google Groups "lint-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lint-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lint-dev/7d5a41a5-13d0-4efe-b237-d75146384e9bn%40googlegroups.com.

colto...@protonmail.com

unread,
Aug 2, 2021, 7:22:50 PM8/2/21
to lint-dev
Reply all
Reply to author
Forward
0 new messages