Refactor: Centralize Spring Boot configuration metadata setup (Phase 2 of #15469)#15571
Open
vigneshsiva11 wants to merge 3 commits intoapache:7.0.xfrom
Open
Refactor: Centralize Spring Boot configuration metadata setup (Phase 2 of #15469)#15571vigneshsiva11 wants to merge 3 commits intoapache:7.0.xfrom
vigneshsiva11 wants to merge 3 commits intoapache:7.0.xfrom
Conversation
Add spring-boot-configuration-processor to the modules that already use @ConfigurationProperties so configuration metadata can be generated automatically and maintained in sync with code.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes Spring Boot configuration metadata annotation-processor setup into the shared Gradle build logic (Phase 2 of #15469), while keeping the processor opt-in and currently enabled only for grails-databinding.
Changes:
- Add an opt-in flag (
enableAnnotationProcessor) tograils-databindingto enable metadata processing. - Extend the shared
CompilePluginto conditionally wirespring-boot-configuration-processor(and BOM alignment) onto theannotationProcessorconfiguration for opted-in modules.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
grails-databinding/build.gradle |
Opts the module into the centralized annotation-processor wiring via ext.enableAnnotationProcessor = true. |
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy |
Adds centralized, opt-in annotation processor configuration to the shared compile convention plugin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import org.gradle.api.Project | ||
| import org.gradle.api.file.DuplicatesStrategy | ||
| import org.gradle.api.plugins.JavaPluginExtension | ||
| import org.gradle.api.tasks.SourceSetContainer |
Comment on lines
+127
to
+128
| def enableProcessor = ext.has('enableAnnotationProcessor') && ext.get('enableAnnotationProcessor') == true | ||
|
|
Comment on lines
+120
to
+122
| // Groovy modules intentionally avoid annotation processors due to incompatibility | ||
| // with incremental Groovy compilation (see issue #15211). | ||
| // Modules must opt-in via 'enableAnnotationProcessor = true' property. |
Comment on lines
+124
to
+140
| try { | ||
| // Check if this module has opted in to annotation processor support | ||
| def ext = project.extensions.extraProperties | ||
| def enableProcessor = ext.has('enableAnnotationProcessor') && ext.get('enableAnnotationProcessor') == true | ||
|
|
||
| if (enableProcessor) { | ||
| // Add annotation processor dependencies for modules with @ConfigurationProperties | ||
| project.configurations.getByName('annotationProcessor').dependencies.add( | ||
| project.dependencies.platform(project.project(':grails-bom')) | ||
| ) | ||
| project.configurations.getByName('annotationProcessor').dependencies.add( | ||
| project.dependencies.create('org.springframework.boot:spring-boot-configuration-processor') | ||
| ) | ||
| } | ||
| } catch (Exception ignored) { | ||
| // Configuration not available for this module | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This change is the step after the first part. It makes the Spring Boot configuration metadata generation better by improving the structure and consistency.
Key Improvements
I put the annotation processor configuration in one place
Removed the setup from each module's build file
i still only enable it for "grails-databinding."
Made sure the metadata generation works as it should without adding risk
This part is about making the code better and putting things together. I do not use the processor for things that I did before.
Problem
In this part I only enabled configuration metadata generation for "grails-databinding" because of some problems.
There were risks with incremental compilation
It was not stable when i used annotation processors for Groovy- modules
But this also caused some issues.
i had to do the configuration many times
It was harder to maintain. i could easily make mistakes
This Change Fixes
I do not have to do the configuration many times
I have control over annotation processing
It is easier to add this feature to things in the future
Technical Details
Build Logic Changes
i made a shared configuration for annotation processors
i put this logic in a place
Modules Updated
grails-databindingNow it uses the shared processor configuration
It works the same as before
Removed
Key Characteristics
i still have to enable annotation processing manually
It only works for "grails-databinding."
It does not change how things are compiled or what the output metadata looks like
Issues
This is related to issue Migrate configuration metadata to @ConfigurationProperties with annotation processor for Grails 8 #15469
It is the step, after Phase 1: Enable Spring Boot configuration metadata processor for existing @ConfigurationProperties modules (#15469) #15566