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

Exclude our own annotation processors from the packaged jar with Maven #10539

Closed
snicoll opened this issue Oct 6, 2017 · 16 comments
Closed

Exclude our own annotation processors from the packaged jar with Maven #10539

snicoll opened this issue Oct 6, 2017 · 16 comments
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@snicoll
Copy link
Member

snicoll commented Oct 6, 2017

Spring Boot uses all defined dependencies (including the ones that are "optional" and "provided").

There is a special cases that Spring Boot supports: annotation processors, one for improving the performance of auto-configuration and the other to generate the meta-data for custom keys. While the former should not land in a final artifact, the latter is a bit more frequent.

There is a way to exclude them using the exclude option of the plugin but perhaps it would be nice to detect them (like we do for devtools). That way, they would be excluded automatically as we know those are definitely not required at runtime.

@snicoll snicoll added for: team-attention An issue we'd like other members of the team to review type: enhancement A general enhancement labels Oct 6, 2017
@filiphr
Copy link
Contributor

filiphr commented Oct 7, 2017

Have you thought to provide different suggestions in how the users should use the annotation processors?

The maven compiler plugin has annotationProcessorPaths where you can put the maven coordinates of the annotation processor and it will pull all the required things and you won't have then in your dependencies.

There is on downside in IntelliJ though. That is: IDEA-150621. However, I think that you would have bigger chances to make Jetbrains pick up the issue and resolve it :).

@philwebb
Copy link
Member

philwebb commented Oct 9, 2017

@filiphr The annotationProcessorPaths option certainly looks like the best long-term solution, but I'm worried that IDEs won't have caught up before we want to release 2.0. We also have Gradle to consider (I'm not sure if they have an equivalent feature or not). If you'd like to raise a new issue we can look into it for a later release.

@philwebb
Copy link
Member

philwebb commented Oct 9, 2017

@snicoll I can't see any downside to adding the excludes. I think we should do it.

@filiphr
Copy link
Contributor

filiphr commented Oct 9, 2017

Only IntelliJ with Maven does not support that. All the others do.

  • Netbeans redirects to Maven to do the build (I am not sure what they do with Gradle)
  • Eclipse supports it for Maven by using m2e-apt and it's <m2e.apt.activation>jdt_apt</m2e.apt.activation>. (I am not entirely sure what they do for Gradle)
  • IntelliJ has issues with maven as I already linked in the issue and for Gradle if it redirects the build to Gradle all is OK (see plugin for Gradle).

For Gradle there is the gradle-apt-plugin that adds new configurations and you add the processors with that configuration.

I can certainly open a new issue if you prefer like that. Just wanted to share my knowledge and give an idea about a possible way of solving this on the long term

@philwebb
Copy link
Member

philwebb commented Oct 9, 2017

@filiphr Yes please to a new issue. We can keep this one for the quick exclude fix and then work on the new issue in the longer term.

@snicoll
Copy link
Member Author

snicoll commented Oct 15, 2017

Only IntelliJ with Maven does not support that.

@filiphr that's the exact reason why it's not referenced that way. Usability in the IDE trumps anything else so I don't see ourselves recommending an approach that doesn't work OOB in an IDE.

@filiphr
Copy link
Contributor

filiphr commented Oct 15, 2017

@snicoll I completely agree with you with this. I wanted to mention an alternative (that might be better for the users), when the IDE things are cleared up of course. I also thought that if a request comes from the Spring Boot team, IntelliJ might have a bigger incentive to fix the issue 😉.

In any case, I am going to open a new issue for my suggestion for the future.

@snicoll
Copy link
Member Author

snicoll commented Oct 15, 2017

I also thought that if a request comes from the Spring Boot team, IntelliJ might have a bigger incentive to fix the issue

Perhaps. I did ask them if they could higher the priority of the issue you've referenced.

@filiphr
Copy link
Contributor

filiphr commented Oct 15, 2017

Perhaps. I did ask them if they could higher the priority of the issue you've referenced.

That is great. It would actually help us in the Annotation Processor Project that I am involved in 😄.

I've also created #10645 as a separate issue to track the progress as we said that we don't want to use this one for changing the approach

@OrangeDog
Copy link
Contributor

OrangeDog commented Jun 25, 2019

IntelliJ supports annotationProcessorPaths now. However, there's no dependency management for them in Maven. Versions will have to be specified via properties, and exclusions are not possible.

However, that appears to break some of lombok's processing, and lombok doesn't appear to work at all when added to annotationProcessorPaths.

@OrangeDog
Copy link
Contributor

OrangeDog commented Nov 12, 2019

Further to annotationProcessorPaths not being great:

@snicoll
Copy link
Member Author

snicoll commented Oct 21, 2020

Superseded by #22036

@snicoll snicoll closed this as completed Oct 21, 2020
@snicoll snicoll removed this from the 2.x milestone Oct 21, 2020
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Oct 21, 2020
@OrangeDog
Copy link
Contributor

The superseding solution doesn't account for other annotation processors, which won't have the Spring Boot manifest entry?

@snicoll
Copy link
Member Author

snicoll commented Oct 21, 2020

Correct but this issue wasn't about those either. We can't do anything smart/out-of-the-box for the things we don't know about.

@OrangeDog
Copy link
Contributor

Ah yes, I was thinking of the similar issues (e.g. #13289). Is #16563 the latest plan for solving it?

@snicoll
Copy link
Member Author

snicoll commented Oct 21, 2020

We don't have any plans to workaround this problem further as it's induced by Maven in the first place. If you can't use annotationProcessorPath you'll have to exclude the artifact by configuration for now I am afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants