Implement Lint aspect
to lint and collect partial results from dependencies
#121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR continues #119 and enhances running lint.
For proper linting, the Lint CLI requires partial linting data from dependencies as well. For example, running lint on the root binary target it needs access to all library target's partial result data as described here.
Since we have variety of macro and rule implementations, it is difficult to modify the graph and add a
Provider
to all targets we can talk to and get this information.Alternatively this PR implements a new Bazel aspect that traverses the build graph and decides whether partial results are required, runs and accumulates and only then runs the root binary lint with all partial results available. Without aspect, we might need to manually connect the linting targets via Grazel which is less than ideal.
Although appears straight forward, there were some challenges.
sources
for aandroid_library/binary
mean it can come from variety of sub targets inside the macro. As aspect is traversing the build graph, it should be able to distinguish all sources vs sub target sources. Thankfuly, there is generator_name attribute that can be used to filter sources only from current macro expansion.BuildConfig.java
is generated but also a source. So instead of assuming this, a new_get_files
function correctly expands the source/generated file. Then these files can be used as expected withaction
andinputs
.Pending