Skip to content

Commit

Permalink
Grails 7 compatibility (#405)
Browse files Browse the repository at this point in the history
- Update to Java 17
- Update to Grails 7
- Update to Groovy 4
- Update to Jakarta
  • Loading branch information
matrei authored Aug 14, 2024
1 parent 6695cb6 commit 61c3802
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"matchPackagePatterns": [
"^org\\.codehaus\\.groovy"
"^org\\.apache\\.groovy"
],
"groupName": "groovy monorepo"
},
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: temurin
java-version: 17
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['11', '14']
java: ['17']
env:
WORKSPACE: ${{ github.workspace }}
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
distribution: temurin
java-version: ${{ matrix.java }}
- name: Run Tests
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Publish to repo.grails.org
id: publish
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '17'
uses: gradle/gradle-build-action@v3
with:
arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish
Expand All @@ -64,7 +64,7 @@ jobs:
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
- name: Generate Docs
id: docs
if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '17'
uses: gradle/gradle-build-action@v3
with:
arguments: docs
Expand All @@ -73,7 +73,7 @@ jobs:
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
- name: Publish to Github Pages
if: steps.docs.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
if: steps.docs.outcome == 'success' && github.event_name == 'push' && matrix.java == '17'
uses: micronaut-projects/github-pages-deploy-action@master
env:
TARGET_REPOSITORY: ${{ github.repository }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: temurin
java-version: 17
- name: Cache local Maven repository & Groovy
uses: actions/cache@v4
with:
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ jobs:
outputs:
release_version: ${{ steps.release_version.outputs.value }}
runs-on: ubuntu-latest
strategy:
matrix:
java: ['11']
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -21,8 +18,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 11
distribution: temurin
java-version: 17
- name: Set the current release version
id: release_version
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -78,8 +75,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: temurin
java-version: 17
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -114,8 +111,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: temurin
java-version: 17
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/retry-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['11']
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@objectcomputing.com
Expand All @@ -27,8 +24,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 17
- name: Extract Target Branch
id: extract_branch
run: |
Expand Down
35 changes: 15 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ subprojects { project ->

ext['groovyVersion'] = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion

configurations.configureEach {

// 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)
}
}
}

ext {
userOrg = "grails"
isGrailsPlugin = name.startsWith('grails-plugin')
Expand All @@ -42,7 +52,6 @@ subprojects { project ->
}

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
if (groovyVersion && groovyVersion.endsWith('-SNAPSHOT')) {
maven {
Expand All @@ -64,30 +73,16 @@ subprojects { project ->
apply from: "${commonBuild}/common-project.gradle"
}

sourceCompatibility = 1.11
targetCompatibility = 1.11
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.springframework') {
details.useVersion(springVersion)
} else if (details.requested.group == 'org.springframework.boot') {
details.useVersion(springBootVersion)
} else if (details.requested.group == 'org.junit.jupiter') {
details.useVersion(junitJupiterVersion)
} else if (details.requested.group == 'org.junit.platform') {
details.useVersion(junitPlatformVersion)
}
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
implementation "com.github.javaparser:javaparser-core:$javaParserVersion"
compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion"
compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"

testImplementation "javax.servlet:javax.servlet-api:$servletApiVersion"
testImplementation "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
testImplementation "org.apache.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
Expand Down
4 changes: 2 additions & 2 deletions examples/demo33/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grailsGradlePluginVersion=6.0.0
grailsVersion=6.0.0
grailsVersion=7.0.0-SNAPSHOT
grailsGradlePluginVersion=6.2.0
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M
Expand Down
4 changes: 2 additions & 2 deletions examples/demo33/grails-app/views/error.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<g:if test="${Throwable.isInstance(exception)}">
<g:renderException exception="${exception}" />
</g:if>
<g:elseif test="${request.getAttribute('javax.servlet.error.exception')}">
<g:renderException exception="${request.getAttribute('javax.servlet.error.exception')}" />
<g:elseif test="${request.getAttribute('jakarta.servlet.error.exception')}">
<g:renderException exception="${request.getAttribute('jakarta.servlet.error.exception')}" />
</g:elseif>
<g:else>
<ul class="errors">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package demo
import grails.testing.web.controllers.ControllerUnitTest
import spock.lang.Specification

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

class SubControllerSpec extends Specification implements ControllerUnitTest<SubController> {
void 'test calling super method'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.grails.web.servlet.mvc.SynchronizerTokensHolder
import spock.lang.Ignore
import spock.lang.Specification

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

class TestControllerSpec extends Specification implements ControllerUnitTest<TestController>, DataTest {

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ projectUrl=https://github.com/grails/grails-testing-support
githubSlug=grails/grails-testing-support
githubBranch=4.0.x
developers=Jeff Brown,James Kleeh
grailsGradlePluginVersion=6.1.2
grailsVersion=6.2.0
grailsGradlePluginVersion=6.2.0
grailsVersion=7.0.0-SNAPSHOT
grailsDocsVersion=6.0.0
asyncVersion=5.0.2
groovyVersion=3.0.21
groovyVersion=4.0.22
gormVersion=8.1.2
jsonViewsVersion=3.2.3
junitPlatformVersion=1.10.2
junitJupiterVersion=5.10.2
gspVersion=6.2.1
spockVersion=2.1-groovy-3.0
springVersion=5.3.33
springBootVersion=2.7.18
slf4jVersion=1.7.22
spockVersion=2.3-groovy-4.0
springVersion=6.1.8
springBootVersion=3.2.6
slf4jVersion=1.7.36
junitVersion=4.12
javassistVersion=3.30.2-GA
servletApiVersion=4.0.1
servletApiVersion=6.0.0
javaParserVersion=3.25.10

org.gradle.caching=true
Expand Down
13 changes: 1 addition & 12 deletions grails-testing-support/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if(details.requested.group == 'org.springframework') {
details.useVersion(springVersion)
}
else if(details.requested.group == 'org.springframework.boot') {
details.useVersion(springBootVersion)
}
}
}

dependencies {
api "org.springframework:spring-test:$springVersion"
api("org.grails:grails-plugin-codecs:$grailsVersion") {
Expand All @@ -25,7 +14,7 @@ dependencies {
api "org.springframework.boot:spring-boot-test:${springBootVersion}"
api("org.spockframework:spock-spring:${spockVersion}") { transitive = false }
api("org.spockframework:spock-core:${spockVersion}") { transitive = false }
api "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
api "org.apache.groovy:groovy-test-junit5:$groovyVersion"
api "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
api "org.junit.platform:junit-platform-runner:$junitPlatformVersion"
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class IntegrationTestMixinTransformation implements ASTTransformation {
// @SpringBootTest
def servletApi = null
try {
servletApi = Class.forName("javax.servlet.ServletContext", false, getClass().classLoader)
servletApi = Class.forName("jakarta.servlet.ServletContext", false, getClass().classLoader)
}
catch(Exception e) {
// ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import org.springframework.util.ClassUtils
@CompileStatic
class GrailsApplicationBuilder {

public static final boolean isServletApiPresent = ClassUtils.isPresent('javax.servlet.ServletContext', GrailsApplicationBuilder.classLoader)
public static final boolean isServletApiPresent = ClassUtils.isPresent('jakarta.servlet.ServletContext', GrailsApplicationBuilder.classLoader)

static final Set DEFAULT_INCLUDED_PLUGINS = ['core', 'eventBus'] as Set

Expand Down
2 changes: 1 addition & 1 deletion grails-web-testing-support/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dependencies {
api "org.grails.plugins:gsp:$gspVersion"
api "org.grails:grails-plugin-rest:$grailsVersion"
api "org.grails:grails-plugin-interceptors:$grailsVersion"
api "javax.servlet:javax.servlet-api:$servletApiVersion"
api "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"

api project(':grails-testing-support')
api "org.javassist:javassist:$javassistVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.spockframework.runtime.extension.IMethodInterceptor
import org.spockframework.runtime.extension.IMethodInvocation
import org.springframework.web.servlet.DispatcherServlet

import javax.servlet.ServletContext
import jakarta.servlet.ServletContext

@CompileStatic
class WebSetupInterceptor implements IMethodInterceptor {
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ include 'grails-testing-support',
'grails-web-testing-support',
'grails-gorm-testing-support'

include 'examples-demo33'
project(":examples-demo33").projectDir = new File(settingsDir, "examples/demo33")
//include 'examples-demo33'
// project(":examples-demo33").projectDir = new File(settingsDir, "examples/demo33")

0 comments on commit 61c3802

Please sign in to comment.