Skip to content

Commit 3dd86cf

Browse files
committed
Switch to jdk 21 and use toolchains to test on older JDK
1 parent 441bdfe commit 3dd86cf

File tree

2 files changed

+64
-19
lines changed

2 files changed

+64
-19
lines changed

.github/workflows/build.yml

+21-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
matrix:
3131
os: [ ubuntu-latest ]
32-
java: [ '11' ]
32+
java: [ '21' ]
3333
steps:
3434
- uses: actions/checkout@v4
3535

@@ -60,15 +60,15 @@ jobs:
6060
strategy:
6161
matrix:
6262
os: [ ubuntu-latest, windows-latest ]
63-
java: [ '8', '11', '17' ]
63+
java: [ '8', '11', '17', '21' ]
6464
steps:
6565
- uses: actions/checkout@v4
6666

6767
- name: Set up JDK ${{ matrix.java }}
6868
uses: actions/setup-java@v4
6969
with:
7070
distribution: temurin
71-
java-version: ${{ matrix.java }}
71+
java-version: ${{ matrix.java }}, 21
7272

7373
- uses: actions/cache@v4
7474
with:
@@ -78,21 +78,33 @@ jobs:
7878
${{ matrix.os }}-maven-
7979
8080
- name: Set up Maven
81+
uses: stCarolas/setup-maven@v5
82+
with:
83+
maven-version: '3.9.8'
84+
85+
- name: Build and test with maven
86+
# Skip all static checks, they were already done in the compile jobs
8187
run:
82-
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.8"
88+
mvn -B --errors --activate-profiles ci,jdk8 "-DjdkToolchainVersion=[,9)" --no-transfer-progress package
89+
if: matrix.java == '8'
90+
91+
- name: Build and test with maven
92+
# Skip all static checks, they were already done in the compile jobs
93+
run:
94+
mvn -B --errors --activate-profiles ci "-DjdkToolchainVersion=[11,12)" --no-transfer-progress package
95+
if: matrix.java == '11'
8396

8497
- name: Build and test with maven
8598
# Skip all static checks, they were already done in the compile jobs
8699
run:
87-
mvnw.cmd -B --errors --activate-profiles ci,jdk${{ matrix.java }} --no-transfer-progress package
88-
shell: cmd
89-
if: matrix.os == 'windows-latest'
100+
mvn -B --errors --activate-profiles ci "-DjdkToolchainVersion=[17,18)" --no-transfer-progress package
101+
if: matrix.java == '17'
90102

91103
- name: Build and test with maven
92104
# Skip all static checks, they were already done in the compile jobs
93105
run:
94-
./mvnw -B --errors --activate-profiles ci,jdk${{ matrix.java }} --no-transfer-progress package
95-
if: matrix.os != 'windows-latest'
106+
mvn -B --errors --activate-profiles ci "-DjdkToolchainVersion=[21,22)" --no-transfer-progress package
107+
if: matrix.java == '21'
96108

97109
- name: Archive test results and logs
98110
# if: success() || failure() to also get the test results on successful runs.

pom.xml

+43-10
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
</scm>
8080

8181
<properties>
82-
<minimalJavaBuildVersion>11</minimalJavaBuildVersion>
82+
<minimalJavaBuildVersion>21</minimalJavaBuildVersion>
83+
<jdkToolchainVersion>[${minimalJavaBuildVersion},)</jdkToolchainVersion>
8384
<minimalMavenBuildVersion>3.9.8</minimalMavenBuildVersion>
8485

8586
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -132,6 +133,47 @@
132133
</properties>
133134

134135
<profiles>
136+
<profile>
137+
<id>toolchains</id>
138+
<activation>
139+
<property>
140+
<name>jdkToolchainVersion</name>
141+
</property>
142+
</activation>
143+
<build>
144+
<plugins>
145+
<plugin>
146+
<groupId>org.apache.maven.plugins</groupId>
147+
<artifactId>maven-toolchains-plugin</artifactId>
148+
<version>3.2.0</version>
149+
<executions>
150+
<execution>
151+
<id>load</id>
152+
<phase>validate</phase>
153+
<goals>
154+
<goal>select-jdk-toolchain</goal>
155+
</goals>
156+
<configuration>
157+
<version>[${minimalJavaBuildVersion},)</version>
158+
<useJdk>Never</useJdk>
159+
</configuration>
160+
</execution>
161+
<execution>
162+
<id>pre-test</id>
163+
<phase>process-test-classes</phase>
164+
<goals>
165+
<goal>select-jdk-toolchain</goal>
166+
</goals>
167+
<configuration>
168+
<version>${jdkToolchainVersion}</version>
169+
<useJdk>Never</useJdk>
170+
</configuration>
171+
</execution>
172+
</executions>
173+
</plugin>
174+
</plugins>
175+
</build>
176+
</profile>
135177
<profile>
136178
<id>jdk8</id>
137179
<properties>
@@ -162,15 +204,6 @@
162204
</plugins>
163205
</build>
164206
</profile>
165-
<profile>
166-
<id>jdk11</id>
167-
</profile>
168-
<profile>
169-
<id>jdk17</id>
170-
</profile>
171-
<profile>
172-
<id>jdk21</id>
173-
</profile>
174207

175208
<profile>
176209
<id>ci</id>

0 commit comments

Comments
 (0)