This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
[improvement] Configure annotation processor classpath explicitly in IDEA #97
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.
Before this PR
Currently, we configure a global "profile" for annotation processors in IDEA.
This profile instructs IDEA to pick up annotation processors from the classpath. At the same time, we manually add all dependencies from the
processor
configuration to the PROVIDED scope in IDEA.This becomes problematic when an annotation processor brings in a different version of a library that already exists on your classpath. Now you get duplicates and behaviour is unexpected as it's not obvious which one will be used during compilation.
Additionally, this leaks all annotation processor dependencies (which are supposed to be implementation details as far as the rest of the program is concerned) onto your PROVIDED scope, so you could accidentally use a class that's not actually in your runtime configuration.
After this PR
The IDEA project is configured with one profile per gradle project, which is assigned to the corresponding IDEA module, and each project's complete set of annotation processors (configuration
allProcessors
) are enumerated in this profile.Furthermore, we don't make IDEA's PROVIDED scope extend
allProcessors
anymore.This means that processors added to gradle 4.6+'s
annotationProcessor
configuration (and equivalents for source sets other thanmain
) don't leak onto your PROVIDED scope anymore.However, we still add dependencies from the original
processor
configuration to PROVIDED in an effort to keep backwards compatibility.Example diff for gradle-sls-packaging: