-
Notifications
You must be signed in to change notification settings - Fork 92
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
Gradle incremental annotation rocessing #373
base: master
Are you sure you want to change the base?
Gradle incremental annotation rocessing #373
Conversation
There's a few constraints that are mentioned on the gradle doc where annotation processors must abide in order to profit from incremental annotation processing, thanks to the current code and best practice the current processor seems to be within the supported scope. https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing
Thanks for the PR @bric3 Unfortunately, Achilles processor cannot be incremental for several reasons:
At that time, this was the only solution to parse nested annotations inside generic types. I don't know if since then things have improved on the front of Java annotation processor to avoid using internal classes. If so I'll be happy to refactor this part of the code to get rid of the Sun internal classes |
Oh I missed those 😅. I have seen other annotation processors using JavaPoet and activating Gradle's incremental processing. In preliminary tests this worked either in isolating and aggregating modes, but the model don't rely on UDT. Maybe I was mislead. Thanks for the quick feedback and the consideration of this feature! |
My bad. The code https://github.com/doanduyhai/Achilles/blob/master/achilles-core/src/main/java/info/archinnov/achilles/internals/apt/processors/meta/AchillesProcessor.java#L118-L162 still uses the Filer API in the end. It is just handled by However the 2nd issue still remains, if I stop using Sun javac internal class, it will break all support of nested annotations |
Hi @doanduyhai
I'd liek to propose the following enhancement: Gradle supports incremental annotation processing, meaning the annotation processor won't have to run on every new compilation.
For that there is a simple guide to follow there to make sure the annotation processor is eligible to incremental annotation processing: https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing
If I'm not mistaken achilles core is ok with these points :
They must generate their files using the Filer API. Writing files any other way will result in silent failures later on, as these files won’t be cleaned up correctly. If your processor does this, it cannot be incremental.
They must not depend on compiler-specific APIs like com.sun.source.util.Trees. Gradle wraps the processing APIs, so attempts to cast to compiler-specific types will fail. If your processor does this, it cannot be incremental, unless you have some fallback mechanism.
If they use Filer#createResource, the location argument must be one of these values from StandardLocation: CLASS_OUTPUT, SOURCE_OUTPUT, or NATIVE_HEADER_OUTPUT. Any other argument will disable incremental processing.
I believe this annotation processor falls aggregatig category as it reaches to other elements like codecs or compiler registry. I followed the specific constraints :
"Aggregating" processors have the following limitations:
The changes looks to be minimal.
If possible it would be great to backport this change to the 5.3.x line.
Thank you in advance for the consideration.