Skip to content

Commit

Permalink
fix: Remove dependency on org.sitemesh:grails-plugin-sitemesh3
Browse files Browse the repository at this point in the history
`grails-gsp` should not depend on an external Grails Plugin.
This dependency was only needed for a `String` constant:
`org.grails.web.sitemesh.GroovyPageLayoutFinder.RENDERING_VIEW_ATTRIBUTE`.

This commit removes the dependency by declaring the same constant
in `GroovyPagesServlet` and using that instead.

Closes #465
  • Loading branch information
matrei committed Jul 27, 2024
1 parent 603acc2 commit 10980da
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 19 deletions.
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ SECTION 2: Apache License, V2.0
>>> jansi-1.11
>>> jsp-api-2.0
>>> log4j-1.2.17
>>> sitemesh-3.1.1
>>> spring-aop-4.0.4
>>> spring-aspects-4.0.4
>>> spring-beans-4.0.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public class GroovyPageParser implements Tokens {
public static final String CONFIG_PROPERTY_GSP_ENCODING = "grails.views.gsp.encoding";
public static final String CONFIG_PROPERTY_GSP_KEEPGENERATED_DIR = "grails.views.gsp.keepgenerateddir";

public static final String CONFIG_PROPERTY_GSP_SITEMESH_PREPROCESS = "grails.views.gsp.sitemesh.preprocess";
public static final String CONFIG_PROPERTY_GSP_COMPILESTATIC = "grails.views.gsp.compileStatic";
public static final String CONFIG_PROPERTY_GSP_ALLOWED_TAGLIB_NAMESPACES = "grails.views.gsp.compileStaticConfig.taglibs";
public static final String CONFIG_PROPERTY_GSP_CODECS = "grails.views.gsp.codecs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class GroovyPagesGrailsPlugin extends Plugin {

public static final String GSP_RELOAD_INTERVAL = "grails.gsp.reload.interval"
public static final String GSP_VIEWS_DIR = 'grails.gsp.view.dir'
public static final String GSP_VIEW_LAYOUT_RESOLVER_ENABLED = 'grails.gsp.view.layoutViewResolver'
public static final String SITEMESH_DEFAULT_LAYOUT = 'grails.sitemesh.default.layout'
public static final String SITEMESH_ENABLE_NONGSP = 'grails.sitemesh.enable.nongsp'

def watchedResources = ["file:./plugins/*/grails-app/taglib/**/*TagLib.groovy",
"file:./grails-app/taglib/**/*TagLib.groovy"]
Expand Down Expand Up @@ -111,16 +108,9 @@ class GroovyPagesGrailsPlugin extends Plugin {
long gspCacheTimeout = config.getProperty(GSP_RELOAD_INTERVAL, Long, (developmentMode && env == Environment.DEVELOPMENT) ? 0L : 5000L)
boolean enableCacheResources = !config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES, Boolean, false)
String viewsDir = config.getProperty(GSP_VIEWS_DIR, '')
boolean enableLayoutViewResolver = config.getProperty(GSP_VIEW_LAYOUT_RESOLVER_ENABLED, Boolean, true)
String defaultDecoratorNameSetting = config.getProperty(SITEMESH_DEFAULT_LAYOUT, '')
def sitemeshEnableNonGspViews = config.getProperty(SITEMESH_ENABLE_NONGSP, Boolean, false)



RuntimeSpringConfiguration spring = springConfig



// resolves JSP tag libraries
if(ClassUtils.isPresent("org.grails.gsp.jsp.TagLibraryResolverImpl", application.classLoader)) {
jspTagLibraryResolver(TagLibraryResolverImpl)
Expand Down
1 change: 0 additions & 1 deletion grails-web-gsp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dependencies {
api project(":grails-gsp")
api "org.grails:grails-web-common:$grailsVersion"
api project(":grails-web-taglib")
api "org.sitemesh:grails-plugin-sitemesh3:6.2.0"

testImplementation "net.bytebuddy:byte-buddy:$byteBuddyVersion"
testRuntimeOnly "org.grails:grails-spring:$grailsVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2004-2005 the original author or authors.
* Copyright 2004-2024 the original author or authors.
*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
Expand All @@ -19,7 +19,6 @@
import grails.plugins.GrailsPluginManager;
import grails.plugins.PluginManagerAware;
import grails.util.GrailsStringUtils;
import org.grails.web.sitemesh.GroovyPageLayoutFinder;
import org.grails.web.util.GrailsApplicationAttributes;
import groovy.text.Template;
import org.grails.core.io.support.GrailsFactoriesLoader;
Expand Down Expand Up @@ -75,6 +74,8 @@ public class GroovyPagesServlet extends FrameworkServlet implements PluginManage

private static final long serialVersionUID = -1918149859392123495L;

public static final String RENDERING_VIEW_ATTRIBUTE = "org.grails.rendering.view";

private static final String WEB_INF = "/WEB-INF";
private static final String GRAILS_APP = "/grails-app";

Expand Down Expand Up @@ -215,7 +216,7 @@ protected GroovyPageScriptSource findPageInBinaryPlugins(String pageName) {
*/
protected void renderPageWithEngine(GroovyPagesTemplateEngine engine, HttpServletRequest request,
HttpServletResponse response, GroovyPageScriptSource scriptSource) throws Exception {
request.setAttribute(GroovyPageLayoutFinder.RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE);
request.setAttribute(RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE);
GSPResponseWriter out = createResponseWriter(response);
try {
Template template = engine.createTemplate(scriptSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
import org.grails.gsp.GroovyPagesTemplateEngine;
import org.grails.gsp.GroovyPagesException;
import org.grails.web.servlet.mvc.GrailsWebRequest;
import org.grails.web.sitemesh.GroovyPageLayoutFinder;
import org.springframework.core.io.Resource;
import org.springframework.scripting.ScriptSource;

import static org.grails.web.pages.GroovyPagesServlet.RENDERING_VIEW_ATTRIBUTE;

/**
* A Spring View that renders Groovy Server Pages to the response. It requires an instance
* of GroovyPagesTemplateEngine to be set and will render to view returned by the getUrl()
Expand Down Expand Up @@ -67,7 +68,7 @@ public class GroovyPageView extends AbstractGrailsView {
@Override
protected void renderTemplate(Map<String, Object> model, GrailsWebRequest webRequest, HttpServletRequest request,
HttpServletResponse response) {
request.setAttribute(GroovyPageLayoutFinder.RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE);
request.setAttribute(RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE);
GSPResponseWriter out = null;
try {
out = createResponseWriter(webRequest, response);
Expand Down

0 comments on commit 10980da

Please sign in to comment.