grab / grab-bazel-common

Common rules and macros for Grab's Android projects built with Bazel.
https://grab.github.io/grazel
Apache License 2.0
39 stars 15 forks source link

Implement lint model in `project.xml` to support additional detectors especially `Gradle` focused ones #156

Closed arunkumar9t2 closed 8 months ago

arunkumar9t2 commented 8 months ago

Context

Certain detectors like MissingTranslation rely on Gradle specific variant field to do checks. When invoking Lint from CLI and using project.xml we don't pass this information thus it is not run. (We don't pass it before because there is no documented way of doing so)

A possible fix is to move completely to lintModel.xml like Gradle does, but it is quite complicated and need lot of ceremony in Bazel to coordinate and setup the correct directories for lint. As an alternate solution, I found that we can pass lintModel.xml to project.xml's model attribute like this. This makes each project to have a variant as expected by many detectors.

Implementation

This PR attempts to create this lintModel.xml using basic information especially passing resourceConfigurations. Other expected components of lint model.xml like dependencies.xml and libraries.xml are empty as they do not seem to be used in my testing.

The generated lintModel.xml has to be passed through the graph similar to partial results, so lint provider is modified accordingly to accomodate that.

Additionally, certain detectors expect resources to be passed as folders instead of files. For example . This PR changes resources to be passed as directory instead.

Added tests and updated sample tests to reflect the changes.

Next