Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrei/groovy4 jakarta #466

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 15 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ buildscript {
}

repositories {
mavenLocal()
//mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}

Expand Down Expand Up @@ -45,8 +46,9 @@ subprojects {
}

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
//mavenLocal()
mavenCentral()
maven { url = "https://repo.grails.org/grails/core" }
}

if (it.name.startsWith("examples")) {
Expand All @@ -68,6 +70,14 @@ subprojects {
targetCompatibility=1.17

configurations.all {

// FORCE UPGRADE OF GROOVY IN DEPENDENCIES TO GROOVY 4
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy') {
details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion)
}
}

resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == "org.spockframework") {
details.useVersion(spockVersion)
Expand All @@ -80,9 +90,9 @@ subprojects {
}

dependencies {
compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion"
compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"

testImplementation "javax.servlet:javax.servlet-api:$servletApiVersion"
testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
testImplementation "org.codehaus.groovy:groovy-test-junit5:${groovyVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
testImplementation "org.junit.platform:junit-platform-runner:${junitPlatformVerison}"
Expand Down
15 changes: 9 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ githubSlug=grails/grails-gsp
githubBranch=7.0.x
developers=Puneet Behl, Graeme Rocher
grailsGradlePluginVersion=6.2.0
grailsVersion=6.2.0
groovyVersion=3.0.21
servletApiVersion=4.0.1
grailsVersion=7.0.0-SNAPSHOT
groovyVersion=4.0.22
annotationApiVersion=3.0.0
byteBuddyVersion=1.14.18
elApiVersion=6.0.1
servletApiVersion=6.0.0
javaParserCoreVersion=3.15.14
jansiVersion=1.18
jlineVersion=2.14.6
jspApiVersion=2.1
jstlVersion=1.1.2
jspApiVersion=4.0.0
jstlVersion=3.0.0
junitJupiterVersion=5.10.2
junitPlatformVerison=1.10.2
spockVersion=2.0-groovy-3.0
spockVersion=2.3-groovy-4.0
slf4jVersion=1.7.32
antVersion=1.10.14
controllersRef=https://docs.grails.org/latest/ref/Controllers
Expand Down
2 changes: 1 addition & 1 deletion grails-gsp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dependencies {
exclude group:'org.grails', module:'grails-spring'
}
api project(":grails-taglib")
api "org.codehaus.groovy:groovy-templates:$groovyVersion"
api "org.apache.groovy:groovy-templates:$groovyVersion"
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-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 Down Expand Up @@ -143,10 +143,10 @@ class ModelRecordingCache {
class ModelEntry {
// defaults are defined by org.grails.web.taglib.WebRequestTemplateVariableBinding
static Map<String, String> DEFAULT_TYPES = [webRequest : 'org.grails.web.servlet.mvc.GrailsWebRequest',
request : 'javax.servlet.http.HttpServletRequest',
response : 'javax.servlet.http.HttpServletResponse',
request : 'jakarta.servlet.http.HttpServletRequest',
response : 'jakarta.servlet.http.HttpServletResponse',
flash : 'grails.web.mvc.FlashScope',
application : 'javax.servlet.ServletContext',
application : 'jakarta.servlet.ServletContext',
applicationContext: 'org.springframework.context.ApplicationContext',
grailsApplication : 'grails.core.GrailsApplication',
session : 'grails.web.servlet.mvc.GrailsHttpSession',
Expand All @@ -155,7 +155,7 @@ class ModelEntry {
controllerName : 'CharSequence']

Map<String, String> model = Collections.synchronizedMap([:])
Set<String> taglibs = Collections.synchronizedSet([] as Set)
Set<String> taglibs = Collections.synchronizedSet([] as Set<String>)
Set<String> defaultTagLibs = new HashSet(GroovyPageParser.DEFAULT_TAGLIB_NAMESPACES)
int initialSize

Expand Down Expand Up @@ -184,7 +184,7 @@ class ModelEntry {
if(defaultType) {
try {
// use default field type for if field type is instance of the class
// for example instance of 'org.apache.catalina.core.ApplicationHttpRequest', use 'javax.servlet.http.HttpServletRequest'
// for example instance of 'org.apache.catalina.core.ApplicationHttpRequest', use 'jakarta.servlet.http.HttpServletRequest'
Class<?> fieldTypeClass = Class.forName(fieldType)
Class<?> defaultTypeClass = Class.forName(defaultType)
if (defaultTypeClass.isAssignableFrom(fieldTypeClass)) {
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 @@ -15,7 +15,6 @@
*/
package org.grails.gsp.compiler;

import grails.config.Config;
import grails.config.ConfigMap;
import grails.io.IOUtils;
import grails.util.Environment;
Expand Down Expand Up @@ -141,7 +140,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
9 changes: 5 additions & 4 deletions grails-plugin-gsp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configurations.all {
}
}
dependencies {
compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion"
compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
api project(":grails-web-gsp-taglib")

runtimeOnly(project(":grails-web-jsp"))
Expand All @@ -34,9 +34,10 @@ dependencies {
}

testRuntimeOnly "org.grails.plugins:async"
testImplementation "javax.servlet.jsp:jsp-api:${jspApiVersion}"
testImplementation "taglibs:standard:${jstlVersion}"
testImplementation "javax.servlet:jstl:${jstlVersion}"
testImplementation "jakarta.annotation:jakarta.annotation-api:$annotationApiVersion"
testImplementation "jakarta.servlet.jsp:jakarta.servlet.jsp-api:${jspApiVersion}"
testRuntimeOnly "org.glassfish.web:jakarta.servlet.jsp.jstl:${jstlVersion}"
testImplementation "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:${jstlVersion}"

testRuntimeOnly "org.grails:grails-plugin-url-mappings:$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 @@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.grails.plugins.web

import grails.config.Config
import grails.core.gsp.GrailsTagLibClass
import grails.gsp.PageRenderer
Expand Down Expand Up @@ -58,9 +59,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 +109,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 Expand Up @@ -230,7 +221,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
}

boolean jstlPresent = ClassUtils.isPresent(
"javax.servlet.jsp.jstl.core.Config", InternalResourceViewResolver.class.getClassLoader())
"jakarta.servlet.jsp.jstl.core.Config", InternalResourceViewResolver.class.getClassLoader())

abstractViewResolver {
prefix = GrailsApplicationAttributes.PATH_TO_VIEWS
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 @@ -27,7 +27,6 @@ import grails.util.GrailsStringUtils
import grails.plugins.GrailsPluginManager
import grails.core.support.GrailsApplicationAware
import grails.web.mapping.LinkGenerator
import grails.web.mapping.UrlMapping
import grails.web.mapping.UrlMappingsHolder
import org.grails.web.servlet.mvc.GrailsWebRequest
import org.codehaus.groovy.runtime.InvokerHelper
Expand All @@ -37,8 +36,8 @@ import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.web.servlet.support.RequestDataValueProcessor

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse

/**
* The base application tag library for Grails many of which take inspiration from Rails helpers (thanks guys! :)
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 @@ -21,7 +21,7 @@ import grails.plugins.GrailsPluginManager
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware

import javax.annotation.PostConstruct
import jakarta.annotation.PostConstruct

/**
* Javascript tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grails.util

import org.springframework.web.servlet.support.RequestDataValueProcessor

import javax.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletRequest

/**
* Created by graemerocher on 12/04/2017.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import grails.testing.web.taglib.TagLibUnitTest
import grails.web.http.HttpHeaders
import org.grails.plugins.web.taglib.ApplicationTagLib
import org.grails.web.pages.GroovyPagesServlet
import org.springframework.context.MessageSource
import org.springframework.web.servlet.support.JstlUtils
import spock.lang.*
import javax.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletRequest
import org.springframework.mock.web.MockHttpServletRequest
import org.springframework.core.io.support.PathMatchingResourcePatternResolver

Expand Down Expand Up @@ -47,7 +45,7 @@ class GroovyPageWithJSPTagsTests extends Specification implements TagLibUnitTest
when:
//JstlUtils.exposeLocalizationContext(request, grailsApplication.mainContext.getBean("messageSource", MessageSource))
def template = '''
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<html>
<body>
<c:forEach var="i" begin="1" end="3"><c:out value="${i}" /> . <c:out value="${i}" /><br/></c:forEach>
Expand Down Expand Up @@ -112,7 +110,7 @@ class GroovyPageWithJSPTagsTests extends Specification implements TagLibUnitTest
def testNestedJSPTags() {
when:
def template = '''
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="jakarta.tags.core" prefix="c" %>
<html>
<head>
<title>test</title>
Expand All @@ -139,7 +137,7 @@ goodbye

def testGSPCantOverrideDefaultNamespaceWithJSP() {
when:
def template = '<%@ taglib prefix="g" uri="http://java.sun.com/jsp/jstl/fmt" %><g:formatNumber number="10" format=".00"/>'
def template = '<%@ taglib prefix="g" uri="jakarta.tags.fmt" %><g:formatNumber number="10" format=".00"/>'
String output = applyTemplate(template)

then:
Expand All @@ -149,7 +147,7 @@ goodbye
def testGSPWithIterativeJSPTag() {
when:
def template = '''
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<g:set var="foo" value="${[1,2,3]}" />
<c:forEach items="${foo}" var="num"><p>${num}</p></c:forEach>
'''
Expand All @@ -162,7 +160,7 @@ goodbye

def testSimpleTagWithValue() {
when:
def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><fmt:formatNumber value="${10}" pattern=".00"/>'
def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %><fmt:formatNumber value="${10}" pattern=".00"/>'
String output = applyTemplate(template)

then:
Expand All @@ -171,7 +169,7 @@ goodbye

def testInvokeJspTagAsMethod() {
when:
def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>${fmt.formatNumber(value:10, pattern:".00")}'
def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>${fmt.formatNumber(value:10, pattern:".00")}'
String output = applyTemplate(template)

then:
Expand All @@ -180,7 +178,7 @@ goodbye

def testInvokeJspTagAsMethodWithBody() {
when:
def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>${fmt.formatNumber(pattern:".00",10)}'
def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>${fmt.formatNumber(pattern:".00",10)}'
String output = applyTemplate(template)

then:
Expand All @@ -189,7 +187,7 @@ goodbye

def testSimpleTagWithBody() {
when:
def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><fmt:formatNumber pattern=".00">10</fmt:formatNumber>'
def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %><fmt:formatNumber pattern=".00">10</fmt:formatNumber>'
String output = applyTemplate(template)

then:
Expand Down
Loading
Loading