matrei commented on issue #16029:
URL: https://github.com/apache/grails-core/issues/16029#issuecomment-5760515454
@zyro23 Following up, since #16269 (which restored a late second pass) was
closed as won't-fix: `resources.groovy` is meant for bean definitions only and
is slated for removal longer term, so this stays a design decision and gets
documented as a breaking change.
**Upgrade notes**
#16359 adds a note to the Grails 8 upgrade guide (under _Plugin Beans Now
Register Before Spring Boot Auto-Configuration_) covering:
- `@Configuration` classes registered in the application's
`resources.groovy` / `resources.xml`, or in the `Application` class's
`doWithSpring` / `beanRegistrar()`, are no longer processed. They become plain
beans and their `@Bean` methods, `@Import` and `@Enable...` annotations are
silently ignored.
- `@Configuration` classes contributed by a *plugin's* `doWithSpring` /
`beanRegistrar()` are unaffected, because plugin beans now register ahead of
Spring's `ConfigurationClassPostProcessor`.
- Replacements: `@Import(MyConfiguration)` or `@ComponentScan` on the
`Application` class, or declaring the beans directly (`resources.groovy`, or
the new `beans` block that @codeconsole mentioned).
- For plugin authors: ship the configuration as a Boot auto-configuration
and expose customization through `@ConditionalOnMissingBean`-guarded beans or
configuration properties, rather than asking users to replace a whole
`@Configuration` class.
**On removing `grailsConfigurationClassPostProcessor`**
It is a no-op in any application started through `SpringApplication`, but it
is not dead code, so I'd leave it. On 8.0.x the registration in
`CoreGrailsPlugin` is guarded:
```groovy
if (!AotDetector.useGeneratedArtifacts() &&
!hasConfigurationClassPostProcessor(application)) {
registry.registerBean('grailsConfigurationClassPostProcessor',
ConfigurationClassPostProcessor)
}
```
It stands down whenever Spring's own processor is present (every
annotation-config context) and under AOT, and only registers on a bare registry
that was assembled without annotation configuration, e.g. a test slice
registering the core plugin's beans. There, it is the only thing that expands
plugin-contributed `@Configuration` classes. It never sees the late
`resources.groovy` content either way, so it is unrelated to this issue.
Once #16359 is merged I think this can be closed as a documented breaking
change.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]