Skip to content

Commit d26b891

Browse files
authoredSep 11, 2024··
chore: add build support for newer JDKs (#948)
Signed-off-by: Todd Baert <[email protected]>

File tree

1 file changed

+75
-13
lines changed

1 file changed

+75
-13
lines changed
 

‎pom.xml

+75-13
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5555
<module-name>${groupId}.${artifactId}</module-name>
5656
<javadoc.failOnWarnings>true</javadoc.failOnWarnings>
57+
<!-- This is required for later correct replacement of surefireArgLine -->
58+
<!-- see surefire-java8 and surefire-java9+ profiles -->
59+
<surefireArgLine/>
5760
</properties>
5861

5962
<dependencies>
@@ -92,6 +95,24 @@
9295
<scope>test</scope>
9396
</dependency>
9497

98+
<!-- Start mockito workaround -->
99+
<!-- https://github.com/mockito/mockito/issues/3121 -->
100+
<!-- These are transitive dependencies of mockito we are forcing -->
101+
<dependency>
102+
<groupId>net.bytebuddy</groupId>
103+
<artifactId>byte-buddy</artifactId>
104+
<version>1.15.1</version>
105+
<scope>test</scope>
106+
</dependency>
107+
108+
<dependency>
109+
<groupId>net.bytebuddy</groupId>
110+
<artifactId>byte-buddy-agent</artifactId>
111+
<version>1.15.1</version>
112+
<scope>test</scope>
113+
</dependency>
114+
<!-- End mockito workaround-->
115+
95116
<dependency>
96117
<groupId>uk.org.lidalia</groupId>
97118
<artifactId>slf4j-test</artifactId>
@@ -206,19 +227,6 @@
206227
<version>3.13.0</version>
207228
</plugin>
208229

209-
<plugin>
210-
<groupId>org.apache.maven.plugins</groupId>
211-
<artifactId>maven-surefire-plugin</artifactId>
212-
<version>3.5.0</version>
213-
<configuration>
214-
<excludes>
215-
<!-- tests to exclude -->
216-
<exclude>${testExclusions}</exclude>
217-
</excludes>
218-
<argLine>${surefireArgLine}</argLine>
219-
</configuration>
220-
</plugin>
221-
222230
<plugin>
223231
<groupId>org.apache.maven.plugins</groupId>
224232
<artifactId>maven-checkstyle-plugin</artifactId>
@@ -433,6 +441,60 @@
433441
</plugins>
434442
</build>
435443

444+
<profiles>
445+
<!-- profile for running tests under java 8 (used mostly in CI) -->
446+
<!-- selected automatically by JDK activeation (see https://maven.apache.org/guides/introduction/introduction-to-profiles.html#implicit-profile-activation) -->
447+
<profile>
448+
<id>surefire-java8</id>
449+
<activation>
450+
<!-- JDK 1.8 -->
451+
<jdk>1.8</jdk>
452+
</activation>
453+
<build>
454+
<plugins>
455+
<plugin>
456+
<groupId>org.apache.maven.plugins</groupId>
457+
<artifactId>maven-surefire-plugin</artifactId>
458+
<version>3.5.0</version>
459+
<configuration>
460+
<excludes>
461+
<!-- tests to exclude -->
462+
<exclude>${testExclusions}</exclude>
463+
</excludes>
464+
<argLine>@{surefireArgLine}</argLine>
465+
</configuration>
466+
</plugin>
467+
</plugins>
468+
</build>
469+
</profile>
470+
471+
<!-- profile for running tests under java 9+ (used for dev environments where people don't want to be locked to Java 8) -->
472+
<!-- selected automatically by JDK activeation (see https://maven.apache.org/guides/introduction/introduction-to-profiles.html#implicit-profile-activation) -->
473+
<profile>
474+
<id>surefire-java9+</id>
475+
<activation>
476+
<!-- JDK 1.9+ -->
477+
<jdk>[1.9,)</jdk>
478+
</activation>
479+
<build>
480+
<plugins>
481+
<plugin>
482+
<groupId>org.apache.maven.plugins</groupId>
483+
<artifactId>maven-surefire-plugin</artifactId>
484+
<version>3.5.0</version>
485+
<configuration>
486+
<excludes>
487+
<!-- tests to exclude -->
488+
<exclude>${testExclusions}</exclude>
489+
</excludes>
490+
<argLine>@{surefireArgLine} --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
491+
</configuration>
492+
</plugin>
493+
</plugins>
494+
</build>
495+
</profile>
496+
</profiles>
497+
436498
<distributionManagement>
437499
<snapshotRepository>
438500
<id>ossrh</id>

0 commit comments

Comments
 (0)
Please sign in to comment.