Skip to content

spring-boot-configuration-processor prevents builds from being incremental when source retention annotations are present #23580

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

Closed
emvag opened this issue Oct 3, 2020 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@emvag
Copy link

emvag commented Oct 3, 2020

Info

Gradle's incremental build doesn't work when using annotations with source retention (@Override, @Generated, Lombok's @Data) and spring-boot-configuration-processor (removing it solves the problem).

Spring Boot version: 2.4.0-M3
Example: https://github.com/ve2m/spring-boot-gradle-incremental-problem

Reproduction steps

  1. git clone [email protected]:ve2m/spring-boot-gradle-incremental-problem.git

  2. ./gradlew compileJava --info

  3. Make some changes to Entity

  4. ./gradlew compileJava --info, note that there is a message saying:

    Full recompilation is required because @Data has source retention.

  5. Comment out annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' in build.gradle

  6. Repeat steps 2-4 and note that incremental build works.

@wilkinsona
Copy link
Member

wilkinsona commented Oct 5, 2020

Thanks for the sample.

This is due to the annotation processor stating that it supports all types of annotations. The processor used to only support @ConfigurationProperties but this was changed in 7e5bb96 to fix #1830.

We do now have some usage of @ConfigurationProperties in spring-boot so the problem described in #1830 wouldn't occur if we reverted 7e5bb96. However, the usage is related to JTA and may well be removed in the not-too-distant future so a revert of 7e5bb96 would fix this problem while reintroducing another one.

I suspect it's quite unusual for a project to have additional configuration property metadata and no usage of @ConfigurationProperties. Given the warning in the javadoc against using * and the problem that it causes with Gradle's incremental compilation, it feels like the problems caused by the fix are broader than the problem that it's solving and that we'd be better finding a solution for #1830 that doesn't affect everyone using spring-boot-configuration-processor.

One option would be to require the use of an annotation processor argument to opt in to supporting all annotation types. This argument could then be set by projects that have an additional metadata file but no usage of @ConfigurationProperties. Another would be to go back to the original fix for #1830 which removed the annotation processor and renamed additional-spring-configuration-metadata.json to spring-configuration-metadata.json.

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 5, 2020
@wilkinsona wilkinsona added this to the 2.4.x milestone Oct 5, 2020
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Oct 5, 2020
@philwebb
Copy link
Member

philwebb commented Oct 5, 2020

We'll list @ConfigurationProperties and @Configuration.

@wilkinsona wilkinsona changed the title Gradle incremental build doesn't work with Configuration Processor spring-boot-configuration-processor prevents builds from being incremental when source retention annotations are present Oct 6, 2020
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.0-M4 Oct 6, 2020
@snicoll
Copy link
Member

snicoll commented Oct 6, 2020

We also generate metadata for org.springframework.boot.actuate.endpoint.annotation.Endpoint so that one should be declared as well.

@snicoll snicoll reopened this Oct 6, 2020
wilkinsona added a commit that referenced this issue Oct 6, 2020
We generate metadata for `@Endpoint` annotated types so the annotation
processor need to indicate that it supports the endpoint annotation.

See gh-23580
@wilkinsona
Copy link
Member

@Endpoint has been added a supported annotation in c825811.

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

No branches or pull requests

5 participants