jdaugherty opened a new pull request, #16462: URL: https://github.com/apache/grails-core/pull/16462
## Description Bug fix split out of #16456, as discussed in its review. `GrailsAppBuilder` only swapped in a `GrailsApp` for the builder it was constructed as. Spring Boot's `child()`, `parent()` and `sibling()` still produced plain `SpringApplicationBuilder`s, so a hierarchy lost the Grails startup defaults, and because the plain parent was launched by a `GrailsApp` it ran the plugin lifecycle too: on 8.0.x, `new GrailsAppBuilder(Shared).child(Application).run(args)` fails with `No bean named 'classLoader' available` while creating `groovyPagesTemplateEngine` in the parent. The builder now owns the hierarchy itself and overrides every Boot fluent method with a covariant `GrailsAppBuilder` return, so every context of a hierarchy is started by a `GrailsApp`. `GrailsApp` records the members of a hierarchy (a package-scoped flag the builder sets) and runs the plugin lifecycle in the one whose sources include the Grails application class, logging at `INFO` when a member leaves it out. A standalone `GrailsApp` keeps running the lifecycle whatever its sources are. The development-mode watch starts only in the context that owns the plugin manager. Covered by `GrailsAppBuilderSpec`, `GrailsAppContextHierarchySpec`, a hierarchy feature of `DevelopmentModeWatchSpec`, and two example applications: a shared Spring parent with a Grails web child, and a command-line program with a non-web Grails parent and a Spring child. Documented in a short section of "Executing the Application Class". What stays in #16456 for 8.1: registering `grailsApplication` and `pluginManager` locally in every context and withdrawing them from the parent when the Grails child closes or fails to start, the refusal of a second Grails application in one hierarchy, the run-status line for contexts without a web server, the public `contextHierarchyMember` property, and the full "Building the Application" page. ## Contributor Checklist ### Issue and Scope - [x] No issue exists; the problem was found while reviewing #16456, and the background is above. - [x] This PR addresses the **complete scope** of the bug fix agreed in that review. - [x] This PR contains a **single, focused change**. - [x] This PR targets the **correct branch**: a bug fix on `8.0.x`, with the feature parts left on `8.1.x`. ### Code Quality - [x] I have **added or updated tests** that cover the changes introduced in this PR. - [x] The covering specs and both example applications pass; CI runs the full build. - [x] My code follows the project's **code style** guidelines (`:grails-core:codeStyle` is clean). - [x] This PR does **not** include mass reformatting, style-only changes, or large-scale refactoring. - [x] Not applicable. ### Licensing and Attribution - [x] All contributed code is provided under the Apache License 2.0, and new source files include the Apache license header. - [x] I have the necessary rights to submit this contribution and confirm it is my own original work. - [x] Not applicable. -- 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]
