Skip to content

Commit cdbb4df

Browse files
committed
disconnect sitemesh2 from gsp; grails-layout or grails-sitemesh must be included by the end application
1 parent 25436ad commit cdbb4df

File tree

40 files changed

+275
-7
lines changed

40 files changed

+275
-7
lines changed

grails-controllers/build.gradle

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

4039
api 'org.apache.groovy:groovy'
4140
api 'org.springframework.boot:spring-boot-autoconfigure'

grails-doc/src/en/guide/upgrading/upgrading60x.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,13 @@ As part of any major release, APIs can change. For Grails 7.0, the list of rena
311311

312312
* GrailsClassUtils#isMatchBetweenPrimativeAndWrapperTypes -> GrailsClassUtils#isMatchBetweenPrimitiveAndWrapperTypes
313313

314-
====== 12.13 Layout Configuration
314+
====== 12.13 Layout Plugins
315315

316-
There are several changes related to layout related configuration:
316+
Grails 7 has two different layout engines: Sitemesh 2.6.x & Sitemesh 3.x. The Sitemesh2 plugin is named `grails-layout` and the Sitemesh 3 plugin is `grails-sitemesh3`. The `grails-layout` plugin is what has traditionally shipped with Grails. The `grails-sitemesh3` plugin is functional, but has some known issues. Please see the thread https://lists.apache.org/thread/8lynrl0yd6ykn749md1g2wjb8jph3s5l[Grails 7 & Reverting Sitemesh 3] for the history of why we did not exclusively use `grails-sitemesh3` for Grails 7.
317+
318+
====== 12.14 grails-layout Configuration
319+
320+
If you decide to use the `grails-layout` plugin, several changes have occurred:
317321

318322
Package Changes:
319323
* grails.web.sitemesh -> org.apache.grails.web.layout
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.grails.forge.feature.sitemesh3;
20+
21+
import jakarta.inject.Singleton;
22+
import org.grails.forge.application.ApplicationType;
23+
import org.grails.forge.application.generator.GeneratorContext;
24+
import org.grails.forge.build.dependencies.Dependency;
25+
import org.grails.forge.feature.Category;
26+
import org.grails.forge.feature.Feature;
27+
28+
@Singleton
29+
public class Sitemesh3 implements Feature {
30+
31+
public Sitemesh3() {
32+
}
33+
34+
@Override
35+
public String getName() {
36+
return "sitemesh3";
37+
}
38+
39+
@Override
40+
public String getTitle() {
41+
return "Sitemesh 3";
42+
}
43+
44+
@Override
45+
public String getDescription() {
46+
return "Adds support for Sitemesh3 based layouts instead of Sitemesh 2";
47+
}
48+
49+
@Override
50+
public void apply(GeneratorContext generatorContext) {
51+
generatorContext.addDependency(Dependency.builder()
52+
.groupId("org.apache.grails")
53+
.artifactId("grails-sitemesh3")
54+
.implementation());
55+
}
56+
57+
@Override
58+
public boolean supports(ApplicationType applicationType) {
59+
return true;
60+
}
61+
62+
@Override
63+
public String getCategory() {
64+
return Category.VIEW;
65+
}
66+
}

grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/view/GrailsGsp.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.grails.forge.feature.DefaultFeature;
2727
import org.grails.forge.feature.Feature;
2828
import org.grails.forge.feature.FeatureContext;
29+
import org.grails.forge.feature.sitemesh3.Sitemesh3;
2930
import org.grails.forge.feature.web.GrailsWeb;
3031
import org.grails.forge.options.Options;
3132
import org.grails.forge.template.URLTemplate;
@@ -103,6 +104,12 @@ public void apply(GeneratorContext generatorContext) {
103104
.groupId("org.apache.grails")
104105
.artifactId("grails-gsp")
105106
.implementation());
107+
if(!generatorContext.isFeaturePresent(Sitemesh3.class)) {
108+
generatorContext.addDependency(Dependency.builder()
109+
.groupId("org.apache.grails")
110+
.artifactId("grails-layout")
111+
.implementation());
112+
}
106113

107114
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
108115
generatorContext.addTemplate("mainLayout", new URLTemplate(getViewFolderPath() + "layouts/main.gsp", classLoader.getResource("gsp/main.gsp")));

grails-gsp/grails-layout/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424
}
2525

2626
version = projectVersion
27-
group = 'org.apache.grails.views'
27+
group = 'org.apache.grails'
2828

2929
ext {
3030
pomTitle = 'Layout Grails Plugin'

grails-gsp/grails-layout/src/main/groovy/org/apache/grails/web/layout/GrailsLayoutGrailsPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GrailsLayoutGrailsPlugin extends Plugin {
4242
def grailsVersion = '7.0.0-SNAPSHOT > *'
4343
def dependsOn = [core: GrailsUtil.getGrailsVersion(), i18n: GrailsUtil.getGrailsVersion()]
4444
def observe = ['controllers']
45-
def loadBefore = ['groovyPages']
45+
def loadAfter = ['groovyPages']
4646

4747
def providedArtefacts = [
4848
RenderGrailsLayoutTagLib,

grails-gsp/plugin/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.grails.plugins.web
2020

2121
import grails.config.Config
22-
import grails.config.Settings
2322
import grails.core.gsp.GrailsTagLibClass
2423
import grails.gsp.PageRenderer
2524
import grails.plugins.Plugin
@@ -79,7 +78,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
7978
def grailsVersion = '7.0.0-SNAPSHOT > *'
8079
def dependsOn = [core: GrailsUtil.getGrailsVersion(), i18n: GrailsUtil.getGrailsVersion()]
8180
def observe = ['controllers']
82-
def loadAfter = ['filters', 'grailsLayout']
81+
def loadAfter = ['filters']
8382

8483
def providedArtefacts = [
8584
ApplicationTagLib,

grails-test-examples/app1/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ dependencies {
3838
implementation 'org.apache.grails:grails-dependencies'
3939
implementation 'org.apache.grails:grails-web-boot'
4040
implementation 'org.apache.grails:grails-core'
41+
if(System.getenv('SITEMESH3_TESTING_ENABLED') == 'true') {
42+
implementation 'org.apache.grails:grails-sitemesh3'
43+
}
44+
else {
45+
implementation 'org.apache.grails:grails-layout'
46+
}
4147

4248
implementation 'org.apache.grails:grails-data-hibernate5'
4349
implementation 'org.apache.grails:grails-cache'

grails-test-examples/app2/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ dependencies {
3838
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
3939
implementation 'org.apache.grails:grails-dependencies'
4040
implementation 'org.apache.grails:grails-web-boot'
41+
if(System.getenv('SITEMESH3_TESTING_ENABLED') == 'true') {
42+
implementation 'org.apache.grails:grails-sitemesh3'
43+
}
44+
else {
45+
implementation 'org.apache.grails:grails-layout'
46+
}
4147

4248
implementation 'org.apache.grails:grails-data-hibernate5'
4349
implementation 'org.apache.grails:grails-cache'

grails-test-examples/app3/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ dependencies {
3636
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
3737
implementation 'org.apache.grails:grails-dependencies'
3838
implementation 'org.apache.grails:grails-web-boot'
39+
if(System.getenv('SITEMESH3_TESTING_ENABLED') == 'true') {
40+
implementation 'org.apache.grails:grails-sitemesh3'
41+
}
42+
else {
43+
implementation 'org.apache.grails:grails-layout'
44+
}
3945

4046
implementation 'org.apache.grails:grails-data-hibernate5'
4147
implementation 'org.apache.grails:grails-cache'

0 commit comments

Comments
 (0)