From 61c38023552c9a269f361829902d7534dcd51106 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Wed, 14 Aug 2024 15:57:16 +0200 Subject: [PATCH] Grails 7 compatibility (#405) - Update to Java 17 - Update to Grails 7 - Update to Groovy 4 - Update to Jakarta --- .github/renovate.json | 2 +- .github/workflows/docs.yml | 4 +-- .github/workflows/gradle.yml | 10 +++--- .github/workflows/groovy-joint-workflow.yml | 4 +-- .github/workflows/release.yml | 15 ++++---- .github/workflows/retry-release.yml | 7 ++-- build.gradle | 35 ++++++++----------- examples/demo33/gradle.properties | 4 +-- examples/demo33/grails-app/views/error.gsp | 4 +-- .../test/groovy/demo/SubControllerSpec.groovy | 2 +- .../groovy/demo/TestControllerSpec.groovy | 2 +- gradle.properties | 16 ++++----- grails-testing-support/build.gradle | 13 +------ .../IntegrationTestMixinTransformation.groovy | 2 +- .../testing/GrailsApplicationBuilder.groovy | 2 +- grails-web-testing-support/build.gradle | 2 +- .../testing/spock/WebSetupInterceptor.groovy | 2 +- settings.gradle | 4 +-- 18 files changed, 54 insertions(+), 76 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 202ed8c6..2f31d795 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -10,7 +10,7 @@ }, { "matchPackagePatterns": [ - "^org\\.codehaus\\.groovy" + "^org\\.apache\\.groovy" ], "groupName": "groovy monorepo" }, diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cfd47c69..8f8dcdd3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 84415119..e397151a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -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 @@ -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' @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index 0465c4d0..5f3b73fc 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77493142..4389db5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 @@ -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: @@ -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: diff --git a/.github/workflows/retry-release.yml b/.github/workflows/retry-release.yml index 99c6450b..ef534566 100644 --- a/.github/workflows/retry-release.yml +++ b/.github/workflows/retry-release.yml @@ -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 @@ -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: | diff --git a/build.gradle b/build.gradle index 07d74bd6..e817affa 100644 --- a/build.gradle +++ b/build.gradle @@ -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') @@ -42,7 +52,6 @@ subprojects { project -> } repositories { - mavenLocal() maven { url "https://repo.grails.org/grails/core" } if (groovyVersion && groovyVersion.endsWith('-SNAPSHOT')) { maven { @@ -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" diff --git a/examples/demo33/gradle.properties b/examples/demo33/gradle.properties index a6c9a6d6..4af099d7 100644 --- a/examples/demo33/gradle.properties +++ b/examples/demo33/gradle.properties @@ -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 diff --git a/examples/demo33/grails-app/views/error.gsp b/examples/demo33/grails-app/views/error.gsp index 9a3bb8aa..a2c4235a 100644 --- a/examples/demo33/grails-app/views/error.gsp +++ b/examples/demo33/grails-app/views/error.gsp @@ -10,8 +10,8 @@ - - + +
    diff --git a/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy b/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy index 7517fbbe..b4302b22 100644 --- a/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy +++ b/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy @@ -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 { void 'test calling super method'() { diff --git a/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy b/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy index aeb122ba..a7522290 100644 --- a/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy +++ b/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy @@ -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, DataTest { diff --git a/gradle.properties b/gradle.properties index abe64562..50d301db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/grails-testing-support/build.gradle b/grails-testing-support/build.gradle index be199939..8694fc30 100755 --- a/grails-testing-support/build.gradle +++ b/grails-testing-support/build.gradle @@ -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") { @@ -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" diff --git a/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy b/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy index f610a108..86d74485 100644 --- a/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy +++ b/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy @@ -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 diff --git a/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy b/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy index cfac66ed..a5e5fc95 100644 --- a/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy +++ b/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy @@ -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 diff --git a/grails-web-testing-support/build.gradle b/grails-web-testing-support/build.gradle index d4e982b0..844f6815 100755 --- a/grails-web-testing-support/build.gradle +++ b/grails-web-testing-support/build.gradle @@ -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" diff --git a/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy b/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy index 78a5dd37..6d5efa7f 100644 --- a/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy +++ b/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy @@ -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 { diff --git a/settings.gradle b/settings.gradle index ea8f7d3f..896b90d2 100755 --- a/settings.gradle +++ b/settings.gradle @@ -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")