Gradle incremental annotation processing metadata support#6999
Open
lihaoyi wants to merge 27 commits intocom-lihaoyi:mainfrom
Open
Gradle incremental annotation processing metadata support#6999lihaoyi wants to merge 27 commits intocom-lihaoyi:mainfrom
lihaoyi wants to merge 27 commits intocom-lihaoyi:mainfrom
Conversation
43aec84 to
c74b4e6
Compare
16b58d0 to
7ea334e
Compare
577e80d to
4bf658e
Compare
609afa3 to
88641fe
Compare
a8d404c to
c75b749
Compare
fe985bd to
01cd37b
Compare
282a841 to
80c706e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Vibe Coded, resolves #6991
Overview
This PR adds incremental annotation-processing support to Mill for Java/Zinc compilation by consuming Gradle-compatible processor metadata from
META-INF/gradle/incremental.annotation.processors.Example contents:
Another example with multiple processors:
Common kind values:
isolatingaggregatingdynamicMill now detects active annotation processors, reads their incremental mode (isolating, aggregating, dynamic), and usesthat to improve incremental cleanup of generated outputs. For supported processors, Mill tracks non-analysis outputs produced under compile.dest/classes, removes stale generated files when their originating source is deleted, and informs Zinc about those removed products so downstream invalidation remains correct. Processor kind parsing is case-insensitive, so jars that declare ISOLATING/AGGREGATING also work. If active processors do not declare supported incremental metadata, Mill falls back to non-incremental compilation rather than risking stale outputs.
Implementation
Zinc does not have any support for incremental annotation processing at all, so we have to do it ourselves by subclassing the Javac compiler and instrumenting the methods we care about. Javac is modular and composed of a bunch of separate objects, so we have to subclass each one and assemble them together ourselves
This does two things:
Lets us extract the information we need to track which generated java file, classfile, or resource came from annotation processing which source file
Lets us intercept the actual annotation processing execution, such that we can use the information extracted above to selectively run or not-run annotation processors on various parts of the codebase
Testing
The PR also adds an unit test suite covering both processor categories with real libraries listed in Gradle’s incremental annotation processor docs: