Register the scaffolding view resolver without the bean DSL#15966
Merged
jdaugherty merged 6 commits intoJul 11, 2026
Conversation
Move the jspViewResolver registration out of doWithSpring() into a ScaffoldingViewResolverDefinitionPostProcessor registered through beanRegistrar(). The post-processor runs at order -2 — before the SiteMesh 2 module's GrailsLayoutViewResolverPostProcessor (-1), which embeds the definition as its inner view resolver, and before the GSP plugin's GroovyPagesPostProcessor (0), which only contributes the plain GSP resolver when no definition exists — so the established resolver pipeline is preserved exactly. An existing jspViewResolver definition still wins, matching the old override semantics. The definition keeps the abstractViewResolver parent template rather than duplicating the GSP resolver defaults, and reads grails.scaffolding.enableNamespaceViewDefaults from the Spring Environment instead of the post-hoc Grails config. With no bean-builder closure left, the plugin descriptor is annotated @CompileStatic.
Pure Spring infrastructure with no Groovy idiom - Java matches the sibling Sitemesh3ViewResolverDefinitionPostProcessor, puts the class under checkstyle, and drops the awkward fully-qualified references that the grails.util.Environment / Spring Environment name clash forced in Groovy.
The declared BeanRegistrar return type already coerces the returned closure; the 'as BeanRegistrar' was redundant.
Hardcoding -2 would silently misorder the resolver pipeline if the GSP post-processor's order ever moved. grails-scaffolding already depends on the GSP plugin at runtime (loadAfter groovyPages, the abstractViewResolver parent bean), so declaring the compile dependency makes the coupling explicit and lets the constant be relative.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15966 +/- ##
==================================================
+ Coverage 49.6092% 49.6359% +0.0267%
- Complexity 16955 16968 +13
==================================================
Files 1999 2000 +1
Lines 93791 93803 +12
Branches 16421 16424 +3
==================================================
+ Hits 46529 46560 +31
+ Misses 40090 40073 -17
+ Partials 7172 7170 -2
🚀 New features to boost your workflow:
|
jdaugherty
approved these changes
Jul 10, 2026
The ordering test asserted against a literal with the collaborators' orders recorded only in a comment, so renumbering GrailsLayoutViewResolverPostProcessor or GroovyPagesPostProcessor would break the pipeline while the test kept passing. It now asserts against the real constants, with grails-layout added as a test dependency. Also correct the stand-down comment: suppression applies to any existing definition, which is stricter than the old doWithSpring() registration that overwrote definitions from earlier-loading plugins.
This comment has been minimized.
This comment has been minimized.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
ScaffoldingGrailsPluginoff the deprecateddoWithSpring()bean DSL (deprecated by #15934) and makes the descriptor fully@CompileStatic— the second in-tree plugin on the modern registration API, following the SiteMesh 3 module in #15964. The two PRs are independent; both preserve the same view-resolver pipeline.Why not a straight
beanRegistrar()portThe old DSL definition relied on
bean.parent = 'abstractViewResolver', and parent/abstract bean templates are one of the DSL constructsBeanRegistrydeliberately has no equivalent for (per #15934). Re-declaring the GSP resolver defaults inside scaffolding would duplicate them and drift.Instead,
beanRegistrar()registers a smallScaffoldingViewResolverDefinitionPostProcessorthat contributes thejspViewResolverdefinition — same class, sameabstractViewResolverparent, samelazyInit— at order -2, which slots into the established post-processor pipeline exactly where the DSL registration used to sit:ScaffoldingViewResolverDefinitionPostProcessor(this PR)GrailsLayoutViewResolverPostProcessor(grails-layout / SiteMesh 2)GroovyPagesPostProcessor(grails-gsp)Sitemesh3ViewResolverDefinitionPostProcessor(#15964)Behavioural parity notes:
jspViewResolverdefinition (applicationresources.groovy, another plugin) still wins, matching the old override semantics.grails.scaffolding.enableNamespaceViewDefaultsis now read from the SpringEnvironmentrather than the Grails config object — equivalent since the config is built from the environment.Environment.current/ development-mode metadata) is unchanged, just relocated.Testing
ScaffoldingViewResolverDefinitionPostProcessorSpeccovering registration (parent template, lazy-init, property values), the environment-drivenenableNamespaceViewDefaults, existing-definition precedence, and the pipeline ordering contract.:grails-scaffolding:testpasses.(view:)URL mappings both render with layouts applied through the SiteMesh 3 view-resolver chain, and the resolver arrives wrapped asGrailsSiteMeshViewResolver[inner=ScaffoldingViewResolver].