Specify custom lint JAR outside of lint tools settings directory

1034 views
Skip to first unread message

Patrick Hammond

unread,
Nov 17, 2013, 12:26:33 PM11/17/13
to adt...@googlegroups.com
If you have custom lint checks that don't make sense to provide in the core set of Android lint checks (they could be library specific, project specific, team coding conventions, etc), you need to manually copy those lint JARs to the current machine's lint tools settings directory (per http://tools.android.com/tips/lint-custom-rules, under 'Register Custom Jar File').  This doesn't feel very portable or flexible.  What I'd like to see is the ability to specify multiple custom lint checks in a project configuration to get this portability and flexibility.

Thinking it through:
  • This feature would probably start with being able to specify paths to additional checks via the Lint CLI.
  • Support for declaring checks as dependencies via Gradle and/or other build scripts.
    • Ideally, you wouldn't need to also update another project configuration to specify inclusion of the checks.
  • IDE support to manage declaring/managing the additional lint checks (not sure what this looks like).
All that said, is there a design reason or constraint that would make this ill advised/impossible?  Is it something already on the roadmap, or now on the roadmap, and just needs some help?

Thanks in advance!
Patrick

Tor Norbye

unread,
Nov 18, 2013, 12:50:48 PM11/18/13
to adt...@googlegroups.com
Lint now automatically looks for extra lint jar files supplied with libraries. For example, the appcompat library (the AAR file that is) can contain a lint.jar with custom rules that perform additional checks for that library. (It doesn't yet, but I used that as a local test when adding the support in lint for this). Then, any app that depends on this library will automatically pull in these extra rules and apply those to the project. This should work in Studio (with gradle projects) today. It should also work with the gradle lint target, but the command line gradle integration is still incomplete.

Right now you have to manually assemble your AAR to contain the custom lint rule jar, but the plan is for it to get automatically built if you have a custom lint rule directory.

-- Tor


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Marius Volkhart

unread,
Dec 22, 2013, 8:22:16 PM12/22/13
to adt...@googlegroups.com
Hi Tor,

Are there any updates on this process since the release of 0.7.1?

Marius Volkhart

unread,
Dec 22, 2013, 9:46:47 PM12/22/13
to adt...@googlegroups.com
Hi Patrick,

How did you write unit tests for you custom lint rule? Is there an easy way to get started? I've only found documentation on how to test AOSP lint checks [1], not custom ones.


Thanks!
Marius

Cheng Yang

unread,
Oct 14, 2014, 2:48:49 PM10/14/14
to adt...@googlegroups.com
Hi Tor

I noticed that the lint check works for app depending on aar file. However, if the app is depending on a library project, even if the lint.jar there and show up in  app/build/intermediates/exploded-aar , the custom rules are not picked up.

Is it expected?

Thanks

Mark Koltnuk

unread,
Aug 25, 2015, 4:39:44 PM8/25/15
to adt-dev
Any news on this?
My custom lint.jar is not picked up. I'm referencing the aar, see it in exploded-aar but nothing :(

thanks!
Reply all
Reply to author
Forward
0 new messages