Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental annotation processing with KAPT #2179

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
4 participants
@gavra0
Copy link
Contributor

gavra0 commented Mar 13, 2019

Add support for incremental annotation processors in KAPT. These
processors conform to https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing
specification.

Support is provided by using javac compiler APIs and
recording the source file structure. At runtime, processors
are instrumented with custom Filer that is used to keep track of generated
files. In order to support classpath changes, stub generation task is
used to generated a list of changed FQCNs, and this is simply used by KAPT.
Both worker and non-worker mode are supported.

Issue is https://youtrack.jetbrains.com/issue/KT-23880

@gavra0 gavra0 force-pushed the gavra0:javac-plugin branch 3 times, most recently from a63ab73 to 1ec6122 Mar 13, 2019

@abelkov abelkov requested a review from alexey-tsvetkov Mar 14, 2019

@abelkov abelkov added the KAPT label Mar 14, 2019

Incremental annotation processing with KAPT
Add support for incremental annotation processors in KAPT. These
processors conform to https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing
specification.

Support is provided by using javac compiler APIs and
recording the source file structure. At runtime, processors
are instrumented with custom Filer that is used to keep track of generated
files. In order to support classpath changes, stub generation task is
used to generated a list of changed FQCNs, and this is simply used by KAPT.
Both worker and non-worker mode are supported.

 #KT-23880

@gavra0 gavra0 force-pushed the gavra0:javac-plugin branch from 1ec6122 to 491aee7 Mar 14, 2019

gavra0 added some commits Mar 15, 2019

Incremental KAPT - handle inherited annotations
Handle annotations with @inherited. This is important for
the aggregating APs, as the current implementation passes all sources
annotated with claimed aggregating annotations.

Issue is https://youtrack.jetbrains.com/issue/KT-23880
Incremental KAPT - invalidate obsolete types
Once set of dirty symbols is computed, filter these types
when they are requested from the JavaFileManager. This is accomplished
by tracking all declared types in the sources and generated sources.
It is not necessary track types in generated class files, as these will
be removed before the APs are incrementally run.

Motivation: APs (e.g. Dagger) may use Elements.getTypeElement(String)
to determine if type is already present, and if it is, they will not
generate it. Therefore, whenever generated sources is invalidated, types
it defines need to be filtered in the JavaFileManager.

Issue is https://youtrack.jetbrains.com/issue/KT-23880

@gavra0 gavra0 force-pushed the gavra0:javac-plugin branch from a850bf9 to f5e691b Mar 15, 2019

@alexey-tsvetkov

This comment has been minimized.

Copy link
Contributor

alexey-tsvetkov commented Mar 20, 2019

LGTM, merged manually. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.