Skip to content

Commit e173174

Browse files
committed
revert sitemesh3 upgrade & rename sitemesh -> layout to ensure license compliance
1 parent 23db393 commit e173174

File tree

91 files changed

+4251
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+4251
-755
lines changed

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,11 @@ This product includes the following files from Spring Framework 5.3, developed b
263263

264264
See the above Apache License 2.0 for the terms governing these files.
265265

266+
--------------------------------------------------------------------------
267+
268+
This product includes software developed by the OpenSymphony Group (http://www.opensymphony.com/). It uses Sitemesh2,
269+
licensed under the OpenSymphony Software License, Version 1.1.
270+
271+
See licenses/LICENSE-opensymphony.txt for the full license terms.
272+
266273
--------------------------------------------------------------------------

NOTICE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html
2525

2626
This product includes software from Spring Framework 5.3, developed by Pivotal Software, Inc.
2727
Copyright 2002-2020 the original author or authors.
28-
See the LICENSE file for the Apache License 2.0 terms.
28+
See the LICENSE file for the Apache License 2.0 terms.
29+
30+
This product includes software developed by the OpenSymphony Group (http://www.opensymphony.com/). It uses Sitemesh2,
31+
licensed under the OpenSymphony Software License, Version 1.1. See licenses/LICENSE-opensymphony.txt for the full license terms.

RENAME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Below is a reference of all migrated artifacts - both their old and new name.
121121
| org.grails.plugins | scaffolding | org.apache.grails | grails-scaffolding | | | grails-views |
122122
| org.grails | grails-plugin-services | org.apache.grails | grails-services | | | grails-core |
123123
| org.grails | grails-shell | org.apache.grails | grails-shell-cli | | | grails-core |
124-
| org.grails | grails-plugin-sitemesh3 | org.apache.grails | grails-sitemesh3 | | | grails-views |
124+
| org.grails.plugins | sitemesh2 | org.apache.grails | grails-layout | | | grails-gsp |
125125
| org.grails | grails-spring | org.apache.grails | grails-spring | | | grails-core |
126126
| org.grails.plugins | spring-security-acl | org.apache.grails | grails-spring-security-acl | | | grails-spring-security |
127127
| org.grails.plugins | spring-security-cas | org.apache.grails | grails-spring-security-cas | | | grails-spring-security |

UPGRADE7.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ Experienced while upgrading modules for Grails 7
4848

4949
### Cool New Features
5050
- Hello Exterminator, Good by bugs! Lot's of things started working... and working well! For instance, use of controller namespaces now work seemlessly.
51-
- Massive decoupling of dependencies and cleanup between modules. SiteMesh dependencies are no longer compiled into controllers fused between numerous modules. SiteMesh isn't even required to use Grails!
52-
- GSP can now be used OUTSIDE of Grails! see grails-boot
51+
- Massive decoupling of dependencies and cleanup between modules.
5352
- Works with Spring Security 6 out of the box. No plugin needed!

dependencies.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ext {
9393
'rxjava3.version' : '3.1.10',
9494
'selenium.version' : '4.25.0',
9595
'spock.version' : '2.3-groovy-4.0',
96+
'sitemesh.version' : '2.6.0',
9697
]
9798

9899
// Note: the name of the dependency must be the prefix of the property name so properties in the pom are resolved correctly
@@ -123,6 +124,7 @@ ext {
123124
'rxjava' : "io.reactivex:rxjava:${bomDependencyVersions['rxjava.version']}",
124125
'rxjava2' : "io.reactivex.rxjava2:rxjava:${bomDependencyVersions['rxjava2.version']}",
125126
'rxjava3' : "io.reactivex.rxjava3:rxjava:${bomDependencyVersions['rxjava3.version']}",
127+
'sitemesh' : "opensymphony:sitemesh:${bomDependencyVersions['sitemesh.version']}",
126128
]
127129

128130
// Because pom exclusions aren't properly supported by gradle, we can't inherit the grails-gradle-bom

etc/bin/rename_gradle_artifacts.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ declare -a views_mappings=(
160160
"org[.]grails:grails-web-gsp-taglib|org.apache.grails.views:grails-web-gsp-taglib"
161161
"org[.]grails:grails-web-gsp|org.apache.grails.views:grails-web-gsp"
162162
"org[.]grails:grails-taglib|org.apache.grails.views:grails-taglib"
163-
"org[.]grails:grails-plugin-sitemesh3|org.apache.grails:grails-sitemesh3"
163+
#"org[.]grails:grails-plugin-sitemesh3|org.apache.grails:grails-sitemesh3"
164+
"org[.]grails[.].plugins:sitemesh2|org.apache.grails:grails-layout"
165+
"org[.]grails:grails-web-sitemesh|org.apache.grails:grails-web-layout"
164166
"org[.]grails:grails-gsp|org.apache.grails.views:grails-gsp-core"
165167
)
166168
declare -a excluded_gsp_mappings=(
@@ -171,7 +173,9 @@ declare -a views_mappings=(
171173
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]scaffolding['\"]|exclude module:'grails-scaffolding'"
172174
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]gsp['\"]|exclude module:'grails-gsp'"
173175
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]grails-web-testing-support['\"]|exclude module:'grails-testing-support-web'"
174-
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]grails-plugin-sitemesh3['\"]|exclude module:'grails-sitemesh3'"
176+
#"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]grails-plugin-sitemesh3['\"]|exclude module:'grails-sitemesh3'"
177+
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]sitemesh2['\"]|exclude module:'grails-layout'"
178+
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]grails-web-sitemesh['\"]|exclude module:'grails-web-layout'"
175179
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]grails-gsp['\"]|exclude module:'grails-gsp-core'"
176180
"exclude[[:space:]]+module[[:space:]]*:[[:space:]]*['\"]fields['\"]|exclude module:'grails-fields'"
177181
)

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ joddWotVersion=3.3.8
3535
elApiVersion=5.0.1
3636
defaultElImplementationVersion=5.0.0
3737
jspApiVersion=4.0.0
38-
sitemeshVersion=3.2.2
3938
javassistVersion=3.30.2-GA
4039
yakworksHibernateGroovyProxyVersion=1.1
4140
picocliVersion=4.7.6
@@ -60,7 +59,7 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx5G
6059
jbossTransactionApiVersion=2.0.0.Final
6160
micronautVersion=4.6.5
6261
micronautSerdeJacksonVersion=2.11.0
63-
grailsSpringSecurityVersion=7.0.0-SNAPSHOT
62+
grailsSpringSecurityVersion=7.0.0-M4
6463

6564
# This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs
6665
# https://github.com/apache/grails-gradle-plugin/issues/222

gradle/publish-root-config.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def publishedProjects = [
6767
'grails-scaffolding',
6868
'grails-services',
6969
'grails-shell-cli',
70-
'grails-sitemesh3',
70+
'grails-layout',
7171
'grails-spring',
7272
'grails-taglib',
7373
'grails-test-core',
@@ -87,6 +87,7 @@ def publishedProjects = [
8787
'grails-web-gsp',
8888
'grails-web-gsp-taglib',
8989
'grails-web-jsp',
90+
'grails-web-layout',
9091
'grails-web-mvc',
9192
'grails-web-taglib',
9293
'grails-web-url-mappings',

grails-controllers/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
api project(':grails-mimetypes')
3636
api project(':grails-validation')
3737
api project(':grails-domain-class')
38+
api project(':grails-web-layout')
3839

3940
api 'org.apache.groovy:groovy'
4041
api 'org.springframework.boot:spring-boot-autoconfigure'

grails-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ import org.grails.web.servlet.mvc.GrailsWebRequest
4040
import org.grails.web.servlet.mvc.exceptions.ControllerExecutionException
4141
import org.grails.web.servlet.view.CompositeViewResolver
4242
import org.grails.web.servlet.view.GroovyPageView
43+
import org.apache.grails.web.layout.EmbeddedGrailsLayoutView
44+
import org.apache.grails.web.layout.GroovyPageLayoutFinder
4345
import org.grails.web.util.GrailsApplicationAttributes
4446
import org.grails.web.util.WebUtils
47+
import org.springframework.beans.factory.NoSuchBeanDefinitionException
4548
import org.springframework.beans.factory.annotation.Autowired
4649
import org.springframework.beans.factory.annotation.Qualifier
4750
import org.springframework.http.HttpStatus
@@ -54,6 +57,7 @@ import jakarta.servlet.http.HttpServletRequest
5457
import jakarta.servlet.http.HttpServletResponse
5558

5659
import static org.grails.plugins.web.controllers.metaclass.RenderDynamicMethod.*
60+
5761
/**
5862
*
5963
* A trait that adds behavior to allow rendering of objects to the response
@@ -70,8 +74,15 @@ trait ResponseRenderer extends WebAttributes {
7074

7175

7276
private MimeUtility mimeUtility
77+
private GroovyPageLayoutFinder groovyPageLayoutFinder
7378
private GrailsPluginManager pluginManager
7479

80+
@Generated
81+
@Autowired(required = false)
82+
void setGroovyPageLayoutFinder(GroovyPageLayoutFinder groovyPageLayoutFinder) {
83+
this.groovyPageLayoutFinder = groovyPageLayoutFinder
84+
}
85+
7586
@Generated
7687
@Autowired(required = false)
7788
@Qualifier("grailsMimeUtility")
@@ -142,7 +153,7 @@ trait ResponseRenderer extends WebAttributes {
142153
else {
143154
renderMarkupInternal webRequest, closure, response
144155
}
145-
setLayout webRequest.currentRequest, layoutArg
156+
applyGrailsLayout webRequest.currentRequest, false, layoutArg
146157
}
147158

148159
private void renderJsonInternal(HttpServletResponse response, @DelegatesTo(value = StreamingJsonBuilder.StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure callable) {
@@ -166,7 +177,7 @@ trait ResponseRenderer extends WebAttributes {
166177
applyContentType response, argMap, body
167178
handleStatusArgument argMap, webRequest, response
168179
render body
169-
setLayout webRequest.currentRequest, layoutArg
180+
applyGrailsLayout webRequest.currentRequest, false, layoutArg
170181
}
171182

172183
/**
@@ -210,7 +221,7 @@ trait ResponseRenderer extends WebAttributes {
210221
handleStatusArgument argMap, webRequest, response
211222
applyContentType response, argMap, writable
212223
renderWritable writable, response
213-
setLayout webRequest.currentRequest, layoutArg
224+
applyGrailsLayout webRequest.currentRequest, false, layoutArg
214225
webRequest.renderView = false
215226
}
216227

@@ -238,7 +249,7 @@ trait ResponseRenderer extends WebAttributes {
238249
CharSequence text = (textArg instanceof CharSequence) ? ((CharSequence)textArg) : textArg.toString()
239250
render text
240251
}
241-
setLayout webRequest.currentRequest, layoutArg
252+
applyGrailsLayout webRequest.currentRequest, false, layoutArg
242253
}
243254
else if (argMap.containsKey(ARGUMENT_VIEW)) {
244255
String viewName = argMap[ARGUMENT_VIEW].toString()
@@ -266,7 +277,7 @@ trait ResponseRenderer extends WebAttributes {
266277
}
267278

268279
((GroovyObject)this).setProperty "modelAndView", new ModelAndView(viewUri, model)
269-
setLayout webRequest.currentRequest, layoutArg
280+
applyGrailsLayout webRequest.currentRequest, true, layoutArg
270281
}
271282
else if (argMap.containsKey(ARGUMENT_TEMPLATE)) {
272283
applyContentType response, argMap, null, false
@@ -301,9 +312,17 @@ trait ResponseRenderer extends WebAttributes {
301312

302313
boolean renderWithLayout = (layoutArg || webRequest.getCurrentRequest().getAttribute(WebUtils.LAYOUT_ATTRIBUTE))
303314
// if automatic decoration occurred unwrap, since this is a partial
315+
if(view instanceof EmbeddedGrailsLayoutView) {
316+
view = ((EmbeddedGrailsLayoutView)view).getInnerView()
317+
}
304318

305-
if (renderWithLayout) {
306-
setLayout webRequest.currentRequest, layoutArg
319+
if(renderWithLayout && groovyPageLayoutFinder) {
320+
applyGrailsLayout webRequest.currentRequest, false, layoutArg
321+
try {
322+
view = new EmbeddedGrailsLayoutView(groovyPageLayoutFinder, view)
323+
} catch (NoSuchBeanDefinitionException e) {
324+
// ignore
325+
}
307326
}
308327

309328

@@ -535,9 +554,14 @@ trait ResponseRenderer extends WebAttributes {
535554
renderArgument instanceof GPathResult ? APPLICATION_XML : defaultEncoding
536555
}
537556

538-
private void setLayout(HttpServletRequest request, String layout) {
539-
if (layout != null && request.getAttribute(WebUtils.LAYOUT_ATTRIBUTE) == null) {
540-
request.setAttribute WebUtils.LAYOUT_ATTRIBUTE, layout
557+
private void applyGrailsLayout(HttpServletRequest request, boolean renderView, String explicitLayoutArg) {
558+
if(explicitLayoutArg == null && request.getAttribute(WebUtils.LAYOUT_ATTRIBUTE) != null) {
559+
// layout has been set already
560+
return
561+
}
562+
String selectedLayout = explicitLayoutArg != null ? explicitLayoutArg : (renderView ? null : GroovyPageLayoutFinder.NONE_LAYOUT)
563+
if(selectedLayout != null) {
564+
request.setAttribute WebUtils.LAYOUT_ATTRIBUTE, selectedLayout
541565
}
542566
}
543567

0 commit comments

Comments
 (0)