Skip to content

Commit

Permalink
Switch to jdk 21 and use toolchains to test on older JDK
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jul 25, 2024
1 parent 441bdfe commit 3dd86cf
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 19 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
java: [ '11' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -60,15 +60,15 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ '8', '11', '17' ]
java: [ '8', '11', '17', '21' ]
steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
java-version: ${{ matrix.java }}, 21

- uses: actions/cache@v4
with:
Expand All @@ -78,21 +78,33 @@ jobs:
${{ matrix.os }}-maven-
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: '3.9.8'

- name: Build and test with maven
# Skip all static checks, they were already done in the compile jobs
run:
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.8"
mvn -B --errors --activate-profiles ci,jdk8 "-DjdkToolchainVersion=[,9)" --no-transfer-progress package
if: matrix.java == '8'

- name: Build and test with maven
# Skip all static checks, they were already done in the compile jobs
run:
mvn -B --errors --activate-profiles ci "-DjdkToolchainVersion=[11,12)" --no-transfer-progress package
if: matrix.java == '11'

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

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

- name: Archive test results and logs
# if: success() || failure() to also get the test results on successful runs.
Expand Down
53 changes: 43 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
</scm>

<properties>
<minimalJavaBuildVersion>11</minimalJavaBuildVersion>
<minimalJavaBuildVersion>21</minimalJavaBuildVersion>
<jdkToolchainVersion>[${minimalJavaBuildVersion},)</jdkToolchainVersion>
<minimalMavenBuildVersion>3.9.8</minimalMavenBuildVersion>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -132,6 +133,47 @@
</properties>

<profiles>
<profile>
<id>toolchains</id>
<activation>
<property>
<name>jdkToolchainVersion</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>load</id>
<phase>validate</phase>
<goals>
<goal>select-jdk-toolchain</goal>
</goals>
<configuration>
<version>[${minimalJavaBuildVersion},)</version>
<useJdk>Never</useJdk>
</configuration>
</execution>
<execution>
<id>pre-test</id>
<phase>process-test-classes</phase>
<goals>
<goal>select-jdk-toolchain</goal>
</goals>
<configuration>
<version>${jdkToolchainVersion}</version>
<useJdk>Never</useJdk>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk8</id>
<properties>
Expand Down Expand Up @@ -162,15 +204,6 @@
</plugins>
</build>
</profile>
<profile>
<id>jdk11</id>
</profile>
<profile>
<id>jdk17</id>
</profile>
<profile>
<id>jdk21</id>
</profile>

<profile>
<id>ci</id>
Expand Down

0 comments on commit 3dd86cf

Please sign in to comment.