codeconsole commented on code in PR #16399:
URL: https://github.com/apache/grails-core/pull/16399#discussion_r4107088549
##########
grails-testing-support-core/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy:
##########
@@ -170,9 +178,18 @@ class GrailsApplicationBuilder {
beanFactory.allowCircularReferences =
environment.getProperty(Settings.SPRING_MAIN_ALLOW_CIRCULAR_REFERENCES,
Boolean, Boolean.TRUE)
def classLoader = this.class.classLoader
+ // The test's own configuration first, as an application's comes
before auto-configuration:
+ // parsed ahead of them, its beans are what an auto-configuration's
@ConditionalOnMissingBean sees.
+ configurationClasses?.each { Class<?> configurationClass ->
Review Comment:
I've reconsidered and closed the gap here instead, in 174b7680d9. The
harness now registers included plugins' `doWithSpring` and `beanRegistrar`
beans before the configuration classes are read, as the early phase does.
- **How:** it adds a post-processor to the context by hand, which Spring
runs ahead of configuration class parsing. That post-processor has the test's
`TestRuntimeGrailsApplicationPostProcessor` register the plugin beans, using
the plugins it loaded and with the test's `doWithConfig` already applied.
- **grails-core hook:** `GrailsApplicationPostProcessor` gains
`isPluginBeanRegistrationDone()`, which is true once the early phase has run.
The harness overrides it so its later pass doesn't register the plugin beans
twice. `applyPluginBeanRegistrars` is now protected for it.
- **Harness defaults:** they still give way to plugin beans, as before.
- **Specs, now pinning parity:**
- `IncludedPluginConditionalBeansSpec`: the plugin's conditional
`fallbackGreeting` backs off from its own `registeredGreeting`, and a plugin
`doWithSpring` bean reading config sees the test's `doWithConfig`.
- `TestConditionalBeanOverIncludedPluginSpec`: the test's conditional bean
backs off.
- `DoWithSpringOverIncludedPluginBeanSpec`: a test's `doWithSpring`
replaces a plugin bean of the same name, as an application's does. It used to
be the other way round.
The three parity features fail with the early post-processor removed. The
warning I'd added to "Spring configuration from plugins" is gone, and the
upgrade guide notes the two behaviour changes for existing tests.
Besides this module's specs, I ran `EarlyPluginRegistrationOrderingSpec`,
GSP's `ApplicationTagLibTests` and several harness users in test-suite-web and
-uber. CI has the rest.
--
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]