You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "vigneshsiva11 (via GitHub)" <gi...@apache.org> on 2026/04/11 16:55:34 UTC
[PR] Centralize configuration processor wiring (Phase 2 for #15469) [grails-core]
vigneshsiva11 opened a new pull request, #15570:
URL: https://github.com/apache/grails-core/pull/15570
## Problem
Phase 1 (PR #15566) scoped Spring Boot configuration metadata generation to `grails-databinding` because applying annotation processors broadly to Groovy modules is incompatible with incremental Groovy compilation (see #15211).
For Phase 2, processor wiring still needed to be centralized so we avoid copy/paste dependency declarations and can safely enable it only where intended.
## Approach
This PR moves processor wiring into shared build logic and introduces explicit module opt-in:
- Added centralized wiring in `CompilePlugin`:
- `configureAnnotationProcessors(project)` is invoked from compile plugin setup.
- Adds:
- `annotationProcessor platform(project(':grails-bom'))`
- `annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'`
- Uses module-local opt-in flag: `ext.enableAnnotationProcessor = true`
- Enabled opt-in only in `grails-databinding`.
- Removed inline processor declarations from Groovy-heavy modules where they are unsafe:
- `grails-cache`
- `grails-views-gson`
- `grails-views-markup`
## Why this is safe
- Default behavior is unchanged for all modules unless they explicitly opt in.
- Groovy modules remain processor-free unless explicitly enabled.
- Keeps the Phase 1 safety direction while reducing future duplication.
## Validation Evidence
Executed on Java 17:
1. Dependency checks
- `:grails-databinding:dependencies --configuration annotationProcessor`
- shows `spring-boot-configuration-processor` and BOM platform dependency
- `:grails-cache:dependencies --configuration annotationProcessor`
- shows `No dependencies`
- `:grails-views-gson:dependencies --configuration annotationProcessor`
- shows `No dependencies`
- `:grails-views-markup:dependencies --configuration annotationProcessor`
- shows `No dependencies`
2. Compile checks
- `:grails-databinding:compileGroovy`
- `:grails-cache:compileGroovy`
- `:grails-views-gson:compileGroovy`
- `:grails-views-markup:compileGroovy`
All completed successfully.
3. Metadata artifact generated
- `grails-databinding/build/classes/groovy/main/META-INF/spring-configuration-metadata.json`
## Related
- Issue: #15469
- Prior phase: PR #15566
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize configuration processor wiring (Phase 2 for #15469) [grails-core]
Posted by "vigneshsiva11 (via GitHub)" <gi...@apache.org>.
vigneshsiva11 closed pull request #15570: Centralize configuration processor wiring (Phase 2 for #15469)
URL: https://github.com/apache/grails-core/pull/15570
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize configuration processor wiring (Phase 2 for #15469) [grails-core]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #15570:
URL: https://github.com/apache/grails-core/pull/15570#discussion_r3068305903
##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -23,11 +23,13 @@ import java.nio.charset.StandardCharsets
import java.util.concurrent.atomic.AtomicBoolean
import groovy.transform.CompileStatic
+import groovy.transform.TypeCheckingMode
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.JavaPluginExtension
+import org.gradle.api.tasks.SourceSetContainer
Review Comment:
`SourceSetContainer` is imported but not used anywhere in this file. The build-logic code style rules include `UnusedImport` / `UnusedImports`, so this will likely fail CodeNarc/Checkstyle—please remove the unused import.
##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -111,6 +114,33 @@ class CompilePlugin implements Plugin<Project> {
}
}
+ @CompileStatic(TypeCheckingMode.SKIP)
+ private static void configureAnnotationProcessors(Project project) {
+ // Configure Spring Boot configuration processor for modules with @ConfigurationProperties.
+ // Groovy modules intentionally avoid annotation processors due to incompatibility
+ // with incremental Groovy compilation (see issue #15211).
+ // Modules must opt-in via 'enableAnnotationProcessor = true' property.
+ project.afterEvaluate {
+ 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
+ }
Review Comment:
`configureAnnotationProcessors` swallows *all* exceptions and silently does nothing. If a module opts in (`enableAnnotationProcessor = true`) and wiring fails (e.g., missing `annotationProcessor` configuration or `:grails-bom` project), this will be hard to detect and can lead to missing metadata generation. Prefer checking `configurations.findByName('annotationProcessor')` / `rootProject.findProject(':grails-bom')` and either fail fast or at least log a warning when opt-in is true but setup cannot be applied; avoid catching generic `Exception`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org