Skip to content

Refactor: Centralize Spring Boot configuration metadata setup (Phase 2 of #15469)#15571

Open
vigneshsiva11 wants to merge 3 commits intoapache:7.0.xfrom
vigneshsiva11:feat/15469-phase2-build-logic-v2
Open

Refactor: Centralize Spring Boot configuration metadata setup (Phase 2 of #15469)#15571
vigneshsiva11 wants to merge 3 commits intoapache:7.0.xfrom
vigneshsiva11:feat/15469-phase2-build-logic-v2

Conversation

@vigneshsiva11
Copy link
Copy Markdown

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-databinding

  • Now it uses the shared processor configuration

  • It works the same as before

Removed

  • i removed the annotation processor setup from each module's build file

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

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.
Copilot AI review requested due to automatic review settings April 11, 2026 17:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) to grails-databinding to enable metadata processing.
  • Extend the shared CompilePlugin to conditionally wire spring-boot-configuration-processor (and BOM alignment) onto the annotationProcessor configuration 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants