Skip to content

Commit

Permalink
Support up to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Sep 20, 2023
1 parent 18b052f commit 3d0120b
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ In order to do so, it is expected that the following system property or properti
* `java17.home`: this property must be set to the location of a Java 17 JDK installation
* `java18.home`: this property must be set to the location of a Java 18 JDK installation
* `java19.home`: this property must be set to the location of a Java 19 JDK installation
* `java20.home`: this property must be set to the location of a Java 20 JDK installation
* `java21.home`: this property must be set to the location of a Java 21 JDK installation

In order to simplify development, it is recommended to project maintainers to set these
properties in your personal Maven `settings.xml` file.
Expand Down Expand Up @@ -163,5 +165,7 @@ Note that this configuration causes the default `JAVA_HOME` environment to be se
|build-test-java17|Run tests for Java 17 when `java17.home` is set and JDK 18 or later is used.|<<mr-jar-testing>>
|build-test-java18|Run tests for Java 18 when `java18.home` is set and JDK 19 or later is used.|<<mr-jar-testing>>
|build-test-java19|Run tests for Java 19 when `java19.home` is set and JDK 20 or later is used.|<<mr-jar-testing>>
|build-test-java20|Run tests for Java 20 when `java20.home` is set and JDK 21 or later is used.|<<mr-jar-testing>>
|build-test-java21|Run tests for Java 21 when `java21.home` is set and JDK 22 or later is used.|<<mr-jar-testing>>
|===

242 changes: 241 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@
</build>
</profile>

<!-- This profile is activated when Java 18 or later is used to build -->
<!-- This profile is activated when Java 19 or later is used to build -->
<profile>
<id>java19-mr-build</id>
<activation>
Expand Down Expand Up @@ -816,6 +816,246 @@
</plugins>
</build>
</profile>

<!-- -->
<!-- Java 20 support -->
<!-- -->

<!-- This profile is activated when the baseline JDK version running tests is Java 20 -->
<profile>
<id>java20-test-classpath</id>
<activation>
<jdk>[20,20)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<configuration>
<classesDirectory>${project.build.outputDirectory}/META-INF/versions/20</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/19</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/18</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/17</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- This profile is activated when Java 20 or later is used to test a project that supports Java 19-->
<profile>
<id>java19-test</id>
<activation>
<jdk>[20,)</jdk>
<property>
<name>java19.home</name>
</property>
<file>
<exists>${basedir}/build-test-java19</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>java19-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<jvm>${java19.home}/bin/java</jvm>
<classesDirectory>${project.build.outputDirectory}/META-INF/versions/19</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/18</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/17</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- This profile is activated when Java 20 or later is used to build -->
<profile>
<id>java20-mr-build</id>
<activation>
<jdk>[20,)</jdk>
<file>
<exists>${basedir}/src/main/java20</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-java20</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>20</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java20</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<!-- -->
<!-- Java 21 support -->
<!-- -->

<!-- This profile is activated when the baseline JDK version running tests is Java 21 -->
<profile>
<id>java21-test-classpath</id>
<activation>
<jdk>[21,21)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<configuration>
<classesDirectory>${project.build.outputDirectory}/META-INF/versions/21</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/20</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/19</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/18</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/17</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- This profile is activated when Java 21 or later is used to test a project that supports Java 20-->
<profile>
<id>java20-test</id>
<activation>
<jdk>[21,)</jdk>
<property>
<name>java20.home</name>
</property>
<file>
<exists>${basedir}/build-test-java20</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>java20-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<jvm>${java20.home}/bin/java</jvm>
<classesDirectory>${project.build.outputDirectory}/META-INF/versions/20</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/19</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/18</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/17</additionalClasspathElement>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- This profile is activated when Java 21 or later is used to build -->
<profile>
<id>java21-mr-build</id>
<activation>
<jdk>[21,)</jdk>
<file>
<exists>${basedir}/src/main/java21</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-java21</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>21</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java21</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- MR JAR support ends here-->
</profiles>
</project>

0 comments on commit 3d0120b

Please sign in to comment.