From a9eafe654a3fa0f6b25e0a5f62ca32ded74bb7be Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 6 Feb 2024 09:03:17 +0100 Subject: [PATCH] feat: Update Java version to 17 (#13352) * feat: Update Java version to 17 BREAKING CHANGE: Requires Java 17 as a minimum version * chore(build): Update Github workflows to Java 17 * chore(build): Remove Java 21 from build workflow * Update groovy-joint-workflow.yml * ci: Build Grails with Java 17 in joint workflow * chore(build): Refactor jvmArgs for tests Make it more clear why these arguments are added by extracting them to a variable with a descriptive name. --------- Co-authored-by: Puneet Behl --- .github/workflows/gradle.yml | 6 ++--- .github/workflows/groovy-joint-workflow.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/retry-release.yml | 2 +- build.gradle | 22 ++++++++++++------- .../groovy/grails/util/GrailsUtilTests.java | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8e00dbf3fdc..5c68d7367da 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['11', '14'] + java: ['17'] env: WORKSPACE: ${{ github.workspace }} steps: @@ -47,11 +47,11 @@ jobs: uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4 with: distribution: 'adopt' - java-version: 11 + java-version: 17 - name: Publish Artifacts (repo.grails.org) id: publish uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index 0335733a6ad..c95952fc259 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -50,7 +50,7 @@ jobs: ~/.m2/repository key: cache-local-groovy-maven-${{ github.sha }} - name: Checkout Groovy 3_0_X (Grails 5 and later) - if: startsWith(github.ref, 'refs/heads/6.') || startsWith(github.base_ref, '6.') || startsWith(github.ref, 'refs/heads/5.') || startsWith(github.base_ref, '5.') + if: startsWith(github.ref, 'refs/heads/7.') || startsWith(github.base_ref, '7.') || startsWith(github.ref, 'refs/heads/6.') || startsWith(github.base_ref, '6.') || startsWith(github.ref, 'refs/heads/5.') || startsWith(github.base_ref, '5.') run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch - name: Set CI_GROOVY_VERSION for Grails id: groovy-version @@ -128,7 +128,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'adopt' - java-version: '11' + java-version: '17' - name: Cache local Maven repository & Groovy uses: actions/cache@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fbc09ee89a0..c8b0eae3a36 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'adopt' - java-version: '11' + java-version: '17' - name: Extract Target Branch id: extract_branch run: | diff --git a/.github/workflows/retry-release.yml b/.github/workflows/retry-release.yml index 897bcba6a68..815437b304c 100644 --- a/.github/workflows/retry-release.yml +++ b/.github/workflows/retry-release.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4 with: distribution: 'adopt' - java-version: 11 + java-version: 17 - name: Extract Target Branch id: extract_branch run: | diff --git a/build.gradle b/build.gradle index 955c78fc039..dff43817e87 100644 --- a/build.gradle +++ b/build.gradle @@ -444,8 +444,8 @@ subprojects { project -> if(project.name == 'grails-dependencies') return if(project.name == 'grails-bom') return - sourceCompatibility = "1.11" - targetCompatibility = "1.11" + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 if(project.name =~ /^(grails-web|grails-plugin-|grails-test-suite|grails-test)/) { dependencies { @@ -533,11 +533,17 @@ subprojects { project -> } } - def debugArguments = ['-Xmx2g', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE', - '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'] - - tasks.withType(Test) { + def debugArguments = [ + '-Xmx2g', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE', + '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' + ] + def java17moduleReflectionCompatibilityArguments = [ + '--add-opens=java.base/java.lang=ALL-UNNAMED', + '--add-opens=java.base/java.util=ALL-UNNAMED' + ] + tasks.withType(Test).configureEach { useJUnitPlatform() + jvmArgs += java17moduleReflectionCompatibilityArguments } test { @@ -566,14 +572,14 @@ subprojects { project -> maxHeapSize = '1024m' } if(System.getProperty("debug.tests")) { - jvmArgs debugArguments + jvmArgs += debugArguments } } task singleTest(type: Test) { // task for running a single test with -DsingleTest.single=TestName singleTest if(System.getProperty("debug.tests")) { - jvmArgs debugArguments + jvmArgs += debugArguments } } diff --git a/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java b/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java index b46538cc662..9aa06c7dc04 100644 --- a/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java +++ b/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java @@ -29,7 +29,7 @@ public class GrailsUtilTests { @Test public void testGrailsVersion() { - assertEquals("6.2.0-SNAPSHOT", GrailsUtil.getGrailsVersion()); + assertEquals("7.0.0-SNAPSHOT", GrailsUtil.getGrailsVersion()); } @AfterEach