You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2026/07/10 20:32:50 UTC

[PR] Register the scaffolding view resolver without the bean DSL [grails-core]

codeconsole opened a new pull request, #15966:
URL: https://github.com/apache/grails-core/pull/15966

   ### Summary
   
   Migrates `ScaffoldingGrailsPlugin` off the deprecated `doWithSpring()` 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()` port
   
   The old DSL definition relied on `bean.parent = 'abstractViewResolver'`, and parent/abstract bean templates are one of the DSL constructs `BeanRegistry` deliberately has no equivalent for (per #15934). Re-declaring the GSP resolver defaults inside scaffolding would duplicate them and drift.
   
   Instead, `beanRegistrar()` registers a small `ScaffoldingViewResolverDefinitionPostProcessor` that contributes the `jspViewResolver` **definition** β€” same class, same `abstractViewResolver` parent, same `lazyInit` β€” at order **-2**, which slots into the established post-processor pipeline exactly where the DSL registration used to sit:
   
   | order | post-processor | behaviour |
   |---|---|---|
   | -2 | `ScaffoldingViewResolverDefinitionPostProcessor` (this PR) | contributes the scaffolding resolver definition unless one exists |
   | -1 | `GrailsLayoutViewResolverPostProcessor` (grails-layout / SiteMesh 2) | embeds the existing definition as its inner view resolver |
   | 0 | `GroovyPagesPostProcessor` (grails-gsp) | contributes the plain GSP resolver only when no definition exists |
   | +10 | `Sitemesh3ViewResolverDefinitionPostProcessor` (#15964) | wraps the definition for SiteMesh 3 decoration |
   
   Behavioural parity notes:
   
   - An existing `jspViewResolver` definition (application `resources.groovy`, another plugin) still wins, matching the old override semantics.
   - `grails.scaffolding.enableNamespaceViewDefaults` is now read from the Spring `Environment` rather than the Grails config object β€” equivalent since the config is built from the environment.
   - The reload-enabled computation (`Environment.current` / development-mode metadata) is unchanged, just relocated.
   
   ### Testing
   
   - New `ScaffoldingViewResolverDefinitionPostProcessorSpec` covering registration (parent template, lazy-init, property values), the environment-driven `enableNamespaceViewDefaults`, existing-definition precedence, and the pipeline ordering contract.
   - `:grails-scaffolding:test` passes.
   - Verified end-to-end on a real application with this module and the #15964 module swapped in together (the eventual merged state): scaffolded controller pages and `(view:)` URL mappings both render with layouts applied through the SiteMesh 3 view-resolver chain, and the resolver arrives wrapped as `GrailsSiteMeshViewResolver[inner=ScaffoldingViewResolver]`.


-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15966:
URL: https://github.com/apache/grails-core/pull/15966#issuecomment-4940732883

   ## 🚨 TestLens detected 1 failed test 🚨
   
   Here is what you can do:
   
   1) Inspect the test failures carefully.
   2) If you are convinced that some of the tests are flaky, you can mute them below.
   3) Finally, trigger a rerun by checking the rerun checkbox.
   
   ### Test Summary
   
   #### [CI / Functional Tests \(Java 25, indy\=false\)](https://github.com/apache/grails-core/actions/runs/29131394088/job/86487282804?pr=15966) > :grails-test-examples-app1:integrationTest
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | AsyncPromiseSpec > multi-stage process reports all stages | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/15938) |
   
   🏷️ Commit: be023f8e425d6b6c2a8abaa6e3a986ab5343f84e
   ▢️ Tests:  12808 executed
   🟑 Checks: 25/53 completed
   
   ### Test Failures
   
   <details>
   
   <summary><strong>AsyncPromiseSpec > multi-stage process reports all stages</strong> (:grails-test-examples-app1:integrationTest in <a href="https://github.com/apache/grails-core/actions/runs/29131394088/job/86487282804?pr=15966">CI / Functional Tests (Java 25, indy=false)</a>)</summary>
   
   ```
   java.net.http.HttpTimeoutException: request timed out
   	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:921)
   	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:133)
   	at org.apache.grails.testing.http.client.HttpClientSupport$Trait$Helper.send(HttpClientSupport.groovy:1133)
   	at org.apache.grails.testing.http.client.HttpClientSupport$Trait$Helper.send(HttpClientSupport.groovy:1122)
   	at org.apache.grails.testing.http.client.HttpClientSupport$Trait$Helper.http(HttpClientSupport.groovy:203)
   	at org.apache.grails.testing.http.client.HttpClientSupport$Trait$Helper.http(HttpClientSupport.groovy:169)
   	at functionaltests.async.AsyncPromiseSpec.multi-stage process reports all stages(AsyncPromiseSpec.groovy:234)
   ```
   
   </details>
   
   ### Muted Tests
   > [!NOTE]
   > Checks are currently running using the configuration below.
   
   Select tests to mute in this pull request:
   
   πŸ”² AsyncPromiseSpec > multi-stage process reports all stages <!-- uniqueId=[engine:spock]/[spec:functionaltests.async.AsyncPromiseSpec]/[feature:$spock_feature_0_12] -->
   
   Reuse successful test results:
   
   πŸ”² ♻️ Only rerun the tests that failed or were muted before
   
   Click the checkbox to trigger a rerun:
   
   πŸ”² **Rerun jobs**
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #15966:
URL: https://github.com/apache/grails-core/pull/15966#discussion_r3562587964


##########
grails-scaffolding/src/main/groovy/grails/plugin/scaffolding/ScaffoldingViewResolverDefinitionPostProcessor.java:
##########
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.plugin.scaffolding;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.Environment;
+
+import grails.util.Metadata;
+import org.grails.plugins.web.GroovyPagesPostProcessor;
+
+/**
+ * Registers the {@code jspViewResolver} bean definition as a
+ * {@link ScaffoldingViewResolver} unless a definition already exists, replacing
+ * the registration the plugin previously performed through the
+ * {@code doWithSpring()} bean DSL. Registering a definition (with the same
+ * {@code abstractViewResolver} parent the GSP plugin's default uses) rather
+ * than building the resolver directly keeps the view-resolver configuration in
+ * one place and preserves the established post-processor pipeline.
+ */
+public class ScaffoldingViewResolverDefinitionPostProcessor implements BeanDefinitionRegistryPostProcessor, EnvironmentAware, Ordered {
+
+    /**
+     * Runs before the SiteMesh 2 module's {@code GrailsLayoutViewResolverPostProcessor}
+     * ({@code GroovyPagesPostProcessor.ORDER - 1}), which embeds the definition
+     * registered here as its inner view resolver, and before
+     * {@link GroovyPagesPostProcessor} itself, which contributes the plain GSP
+     * resolver only when no definition exists by then.
+     */
+    public static final int ORDER = GroovyPagesPostProcessor.ORDER - 2;
+
+    private static final String JSP_VIEW_RESOLVER_BEAN_NAME = "jspViewResolver";
+
+    private Environment environment;
+
+    @Override
+    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
+        if (registry.containsBeanDefinition(JSP_VIEW_RESOLVER_BEAN_NAME)) {
+            // an application- or plugin-supplied view resolver wins

Review Comment:
   Confirmed intentional β€” stand-down-if-present is the contract, consistent with `GroovyPagesPostProcessor`. You're right that my "matching the old override semantics" claim was only true for application precedence, not plugin-vs-plugin: the old `doWithSpring()` registration overwrote definitions from earlier-loading plugins, and this doesn't. Fixed the inline comment in be023f8e42 to state "any existing definition wins" and to note explicitly that this is stricter than the DSL registration was.



##########
grails-scaffolding/src/test/groovy/grails/plugin/scaffolding/ScaffoldingViewResolverDefinitionPostProcessorSpec.groovy:
##########
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.plugin.scaffolding
+
+import org.springframework.beans.factory.config.BeanDefinition
+import org.springframework.beans.factory.support.DefaultListableBeanFactory
+import org.springframework.beans.factory.support.GenericBeanDefinition
+import org.springframework.core.env.MapPropertySource
+import org.springframework.core.env.StandardEnvironment
+import org.springframework.web.servlet.view.InternalResourceViewResolver
+
+import spock.lang.Specification
+
+class ScaffoldingViewResolverDefinitionPostProcessorSpec extends Specification {
+
+    ScaffoldingViewResolverDefinitionPostProcessor postProcessor = new ScaffoldingViewResolverDefinitionPostProcessor()
+
+    void "registers the scaffolding view resolver definition with the GSP parent template"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        postProcessor.environment = new StandardEnvironment()
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+        BeanDefinition definition = registry.getBeanDefinition('jspViewResolver')
+
+        then:
+        definition.beanClassName == ScaffoldingViewResolver.name
+        definition.parentName == 'abstractViewResolver'
+        definition.lazyInit
+        definition.propertyValues.contains('enableReload')
+        definition.propertyValues.getPropertyValue('enableNamespaceViewDefaults').value == false
+    }
+
+    void "the enableNamespaceViewDefaults property is read from the environment"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        StandardEnvironment environment = new StandardEnvironment()
+        environment.propertySources.addFirst(
+                new MapPropertySource('test', ['grails.scaffolding.enableNamespaceViewDefaults': 'true']))
+        postProcessor.environment = environment
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+
+        then:
+        registry.getBeanDefinition('jspViewResolver')
+                .propertyValues.getPropertyValue('enableNamespaceViewDefaults').value == true
+    }
+
+    void "an existing jspViewResolver definition wins"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        registry.registerBeanDefinition('jspViewResolver',
+                new GenericBeanDefinition(beanClass: InternalResourceViewResolver))
+        postProcessor.environment = new StandardEnvironment()
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+
+        then:
+        registry.getBeanDefinition('jspViewResolver').beanClassName == InternalResourceViewResolver.name
+    }
+
+    void "runs before the SiteMesh 2 layout post-processor and the GSP default post-processor"() {
+        expect: "GrailsLayoutViewResolverPostProcessor runs at -1 and GroovyPagesPostProcessor at 0"
+        postProcessor.order < -1

Review Comment:
   Done in be023f8e42 β€” the test now asserts against both real constants (`new GrailsLayoutViewResolverPostProcessor().order` and `GroovyPagesPostProcessor.ORDER`), with `grails-layout` added as a `testImplementation` dependency. That dep felt justified rather than merely tolerable: the -2 slot exists precisely because grails-layout's post-processor embeds this definition at -1, so the contract test naming that collaborator directly is the point.



-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #15966:
URL: https://github.com/apache/grails-core/pull/15966#issuecomment-4939680909

   ## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/15966?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `76.19048%` with `5 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 49.6194%. Comparing base ([`81aa7c2`](https://app.codecov.io/gh/apache/grails-core/commit/81aa7c2c3b0d48b22a11930b47707542b2468baa?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`23a83ed`](https://app.codecov.io/gh/apache/grails-core/commit/23a83ed1765ecc50755c2692bbbadbe9657c5830?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on 8.0.x.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/grails-core/pull/15966?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...caffoldingViewResolverDefinitionPostProcessor.java](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&filepath=grails-scaffolding%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fscaffolding%2FScaffoldingViewResolverDefinitionPostProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLXNjYWZmb2xkaW5nL3NyYy9tYWluL2dyb292eS9ncmFpbHMvcGx1Z2luL3NjYWZmb2xkaW5nL1NjYWZmb2xkaW5nVmlld1Jlc29sdmVyRGVmaW5pdGlvblBvc3RQcm9jZXNzb3IuamF2YQ==) | 84.2105% | [0 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../plugin/scaffolding/ScaffoldingGrailsPlugin.groovy](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&filepath=grails-scaffolding%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fscaffolding%2FScaffoldingGrailsPlugin.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLXNjYWZmb2xkaW5nL3NyYy9tYWluL2dyb292eS9ncmFpbHMvcGx1Z2luL3NjYWZmb2xkaW5nL1NjYWZmb2xkaW5nR3JhaWxzUGx1Z2luLmdyb292eQ==) | 0.0000% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/grails-core/pull/15966/graphs/tree.svg?width=650&height=150&src=pr&token=qJrryhpk7u&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##                8.0.x     #15966        +/-   ##
   ==================================================
   + Coverage     49.6092%   49.6194%   +0.0102%     
   - Complexity      16955      16962         +7     
   ==================================================
     Files            1999       2000         +1     
     Lines           93791      93804        +13     
     Branches        16421      16424         +3     
   ==================================================
   + Hits            46529      46545        +16     
   + Misses          40090      40089         -1     
   + Partials         7172       7170         -2     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/grails-core/pull/15966?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ” | |
   |---|---|---|
   | [.../plugin/scaffolding/ScaffoldingGrailsPlugin.groovy](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&filepath=grails-scaffolding%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fscaffolding%2FScaffoldingGrailsPlugin.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLXNjYWZmb2xkaW5nL3NyYy9tYWluL2dyb292eS9ncmFpbHMvcGx1Z2luL3NjYWZmb2xkaW5nL1NjYWZmb2xkaW5nR3JhaWxzUGx1Z2luLmdyb292eQ==) | `0.0000% <0.0000%> (ΓΈ)` | |
   | [...caffoldingViewResolverDefinitionPostProcessor.java](https://app.codecov.io/gh/apache/grails-core/pull/15966?src=pr&el=tree&filepath=grails-scaffolding%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fscaffolding%2FScaffoldingViewResolverDefinitionPostProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLXNjYWZmb2xkaW5nL3NyYy9tYWluL2dyb292eS9ncmFpbHMvcGx1Z2luL3NjYWZmb2xkaW5nL1NjYWZmb2xkaW5nVmlld1Jlc29sdmVyRGVmaW5pdGlvblBvc3RQcm9jZXNzb3IuamF2YQ==) | `84.2105% <84.2105%> (ΓΈ)` | |
   
   ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/15966/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15966:
URL: https://github.com/apache/grails-core/pull/15966#discussion_r3562539534


##########
grails-scaffolding/src/main/groovy/grails/plugin/scaffolding/ScaffoldingViewResolverDefinitionPostProcessor.java:
##########
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.plugin.scaffolding;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.Environment;
+
+import grails.util.Metadata;
+import org.grails.plugins.web.GroovyPagesPostProcessor;
+
+/**
+ * Registers the {@code jspViewResolver} bean definition as a
+ * {@link ScaffoldingViewResolver} unless a definition already exists, replacing
+ * the registration the plugin previously performed through the
+ * {@code doWithSpring()} bean DSL. Registering a definition (with the same
+ * {@code abstractViewResolver} parent the GSP plugin's default uses) rather
+ * than building the resolver directly keeps the view-resolver configuration in
+ * one place and preserves the established post-processor pipeline.
+ */
+public class ScaffoldingViewResolverDefinitionPostProcessor implements BeanDefinitionRegistryPostProcessor, EnvironmentAware, Ordered {
+
+    /**
+     * Runs before the SiteMesh 2 module's {@code GrailsLayoutViewResolverPostProcessor}
+     * ({@code GroovyPagesPostProcessor.ORDER - 1}), which embeds the definition
+     * registered here as its inner view resolver, and before
+     * {@link GroovyPagesPostProcessor} itself, which contributes the plain GSP
+     * resolver only when no definition exists by then.
+     */
+    public static final int ORDER = GroovyPagesPostProcessor.ORDER - 2;
+
+    private static final String JSP_VIEW_RESOLVER_BEAN_NAME = "jspViewResolver";
+
+    private Environment environment;
+
+    @Override
+    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
+        if (registry.containsBeanDefinition(JSP_VIEW_RESOLVER_BEAN_NAME)) {
+            // an application- or plugin-supplied view resolver wins

Review Comment:
   The plugin-vs-plugin direction of this precedence actually flips relative to the old DSL registration, so "matching the old override semantics" isn't quite exact. Previously the definition was registered during the `doWithSpring()` drain in plugin load order: scaffolding (`loadAfter = ['groovyPages']`) *overwrote* a `jspViewResolver` registered by any plugin loading before it, and was itself overwritten by plugins loading after it and by the application's `resources.groovy`. Now any definition present after the drain β€” including one from a plugin that loads *before* scaffolding β€” suppresses this registration.
   
   Application precedence is preserved, and stand-down-if-present is arguably the better contract (it's what `GroovyPagesPostProcessor` does), so this is probably fine β€” just confirming the flip is intentional, and the inline comment could say "any existing definition wins" rather than claiming parity with the old override semantics.



##########
grails-scaffolding/src/test/groovy/grails/plugin/scaffolding/ScaffoldingViewResolverDefinitionPostProcessorSpec.groovy:
##########
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.plugin.scaffolding
+
+import org.springframework.beans.factory.config.BeanDefinition
+import org.springframework.beans.factory.support.DefaultListableBeanFactory
+import org.springframework.beans.factory.support.GenericBeanDefinition
+import org.springframework.core.env.MapPropertySource
+import org.springframework.core.env.StandardEnvironment
+import org.springframework.web.servlet.view.InternalResourceViewResolver
+
+import spock.lang.Specification
+
+class ScaffoldingViewResolverDefinitionPostProcessorSpec extends Specification {
+
+    ScaffoldingViewResolverDefinitionPostProcessor postProcessor = new ScaffoldingViewResolverDefinitionPostProcessor()
+
+    void "registers the scaffolding view resolver definition with the GSP parent template"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        postProcessor.environment = new StandardEnvironment()
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+        BeanDefinition definition = registry.getBeanDefinition('jspViewResolver')
+
+        then:
+        definition.beanClassName == ScaffoldingViewResolver.name
+        definition.parentName == 'abstractViewResolver'
+        definition.lazyInit
+        definition.propertyValues.contains('enableReload')
+        definition.propertyValues.getPropertyValue('enableNamespaceViewDefaults').value == false
+    }
+
+    void "the enableNamespaceViewDefaults property is read from the environment"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        StandardEnvironment environment = new StandardEnvironment()
+        environment.propertySources.addFirst(
+                new MapPropertySource('test', ['grails.scaffolding.enableNamespaceViewDefaults': 'true']))
+        postProcessor.environment = environment
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+
+        then:
+        registry.getBeanDefinition('jspViewResolver')
+                .propertyValues.getPropertyValue('enableNamespaceViewDefaults').value == true
+    }
+
+    void "an existing jspViewResolver definition wins"() {
+        given:
+        DefaultListableBeanFactory registry = new DefaultListableBeanFactory()
+        registry.registerBeanDefinition('jspViewResolver',
+                new GenericBeanDefinition(beanClass: InternalResourceViewResolver))
+        postProcessor.environment = new StandardEnvironment()
+
+        when:
+        postProcessor.postProcessBeanDefinitionRegistry(registry)
+
+        then:
+        registry.getBeanDefinition('jspViewResolver').beanClassName == InternalResourceViewResolver.name
+    }
+
+    void "runs before the SiteMesh 2 layout post-processor and the GSP default post-processor"() {
+        expect: "GrailsLayoutViewResolverPostProcessor runs at -1 and GroovyPagesPostProcessor at 0"
+        postProcessor.order < -1

Review Comment:
   This assertion hardcodes the collaborators' orders (-1 and 0) in a comment rather than checking them, so if `GrailsLayoutViewResolverPostProcessor` or `GroovyPagesPostProcessor` were ever renumbered the test would keep passing while the pipeline contract silently broke. Asserting against the real constants pins the contract:
   
   ```groovy
   postProcessor.order < new GrailsLayoutViewResolverPostProcessor().order
   postProcessor.order < GroovyPagesPostProcessor.ORDER
   ```
   
   (the second works with the existing `implementation project(':grails-gsp')`; the first needs a `testImplementation project(':grails-layout')` β€” if that dependency isn't wanted, at least the `GroovyPagesPostProcessor.ORDER` half is free).



-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15966:
URL: https://github.com/apache/grails-core/pull/15966#issuecomment-4940042590

   ## βœ… All tests passed βœ…
   
   🏷️ Commit: 23a83ed1765ecc50755c2692bbbadbe9657c5830
   ▢️ Tests:  20932 executed
   βšͺ️ Checks: 59/59 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
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] Register the scaffolding view resolver without the bean DSL [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty merged PR #15966:
URL: https://github.com/apache/grails-core/pull/15966


-- 
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