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

Disable annotation processing in AOT compilation step #38711

Open
snicoll opened this issue Dec 8, 2023 · 6 comments
Open

Disable annotation processing in AOT compilation step #38711

snicoll opened this issue Dec 8, 2023 · 6 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Dec 8, 2023

By default, the compiler attempts to discover annotation processors from the classpath. This can have side effect on code that is generated ahead of time.

Adding -proc:none in the Maven and Gradle integration could be on way of making sure these don't run.

See also spring-projects/spring-framework#30824 which now annotates every generated class which should trigger a warning if AP is active and no processor claimed it (which is likely to happen).

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged label Dec 8, 2023
@wilkinsona
Copy link
Member

We may not need to do anything for Gradle builds. Gradle should ignore annotation processors on the compile classpath and only use those declared in the aotAnnotationProcessor configuration. If a user's made such a declaration I think we should honour it as it's very unlikely that it has been done accidentally.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 12, 2023
@philwebb
Copy link
Member

@snicoll Do you have a sample project available that produces the warning?

@philwebb philwebb added status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Dec 14, 2023
@philwebb philwebb added this to the 3.x milestone Dec 14, 2023
@snicoll
Copy link
Member Author

snicoll commented Dec 14, 2023

Nope, sorry. I had the warning in framework tests using TestCompiler as it used to detects annotation processors from the classpath. I suspect that maybe the warnings from the compiler in the Maven plugin may not be redirected to the logs? I've tried to reproduce with a vanilla app and the context indexer and that didn't work. But I can see now that's because it claims all annotations. I'll have to dig a bit more.

Regardless, the issue is not really about the warning, but about the fact that, if I am not mistaken, AP (at least with Maven) are invoked by the AOT compilation run and shouldn't.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 14, 2023
@philwebb

This comment was marked as outdated.

@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Feb 15, 2024
@philwebb
Copy link
Member

After some more discussion with @snicoll things have become a bit clearer. We're not looking to disable annotation processing of user code, rather we'd want to make a change to this part of ProcessAotMojo so that annotation processors are not invoked on generated code.

@philwebb philwebb removed the status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team label Feb 15, 2024
@wilkinsona
Copy link
Member

We don't have complete control over the code that's generated. It's possible that someone has written a custom code generation contribution that relies on annotation processing. If we made this change, it would break them so I wonder if we'd also need to add a way to reverse it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants