Skip to content

Commit

Permalink
feat: Update Java version to 17 (grails#13352)
Browse files Browse the repository at this point in the history
* 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 <behlp@unityfoundation.io>
  • Loading branch information
matrei and puneetbehl authored Feb 6, 2024
1 parent d1cb568 commit a9eafe6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['11', '14']
java: ['17']
env:
WORKSPACE: ${{ github.workspace }}
steps:
Expand Down Expand Up @@ -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
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 @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/retry-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
22 changes: 14 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9eafe6

Please sign in to comment.