File tree Expand file tree Collapse file tree 3 files changed +33
-24
lines changed Expand file tree Collapse file tree 3 files changed +33
-24
lines changed Original file line number Diff line number Diff line change @@ -12,15 +12,11 @@ jobs:
1212 - uses : actions/setup-java@v5
1313 with :
1414 distribution : temurin
15- # The target JDK is used to build, the latest one to run Gradle itself (we cannot use Java 8 for Gradle)
15+ # The latest JDK is used to build, the version from the matrix is used to run the tests, to check compatibility.
1616 java-version : |
1717 ${{ matrix.java-version }}
1818 21
1919
20- # delete gradle.properties in Java 8 because it contains a then-unsupported JVM argument: --add-exports
21- - run : rm gradle.properties
22- if : ${{ matrix.java-version == 8 }}
23-
2420 - run : ./gradlew assemble check --info
2521 env :
26- JAVA_TOOLCHAIN : ${{ matrix.java-version }}
22+ TEST_JAVA_TOOLCHAIN : ${{ matrix.java-version }}
Original file line number Diff line number Diff line change @@ -6,28 +6,16 @@ plugins {
66 id " com.diffplug.spotless" version " 7.2.1"
77}
88
9- var javaToolchain = System . getenv(' JAVA_TOOLCHAIN' )
10-
11- java {
12- if (javaToolchain != null ) {
13- toolchain {
14- languageVersion = JavaLanguageVersion . of(javaToolchain)
15- }
16- }
17- }
18-
199compileJava {
20- if (javaToolchain != " 8" ) {
21- options. release = 8
22- }
23- options. compilerArgs. add(' -Xlint' )
10+ options. release = 8
11+ // for some reason javac warns the previous option, disabling
12+ options. compilerArgs. add(' -Xlint:all,-options' )
2413}
2514
2615compileTestJava {
27- if (javaToolchain != " 8" ) {
28- options. release = 8
29- }
30- options. compilerArgs. add(' -Xlint' )
16+ options. release = 8
17+ // for some reason javac warns the previous option, disabling
18+ options. compilerArgs. add(' -Xlint:all,-options' )
3119}
3220
3321repositories {
@@ -48,6 +36,17 @@ testing {
4836 suites {
4937 test {
5038 useJUnitJupiter()
39+ targets {
40+ all {
41+ testTask. configure {
42+ javaLauncher. set(
43+ javaToolchains. launcherFor {
44+ languageVersion. set(JavaLanguageVersion . of(System . getenv(' TEST_JAVA_TOOLCHAIN' )))
45+ }
46+ )
47+ }
48+ }
49+ }
5150 }
5251 }
5352}
Original file line number Diff line number Diff line change 1+ package lbmq ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ /**
6+ * Not really a test, but a way of confirming that tests are running with the intended JVM version.
7+ */
8+ public class VersionLoggerTest {
9+
10+ @ Test
11+ public void versionLogger () {
12+ System .out .printf ("Running in JVM version %s\n " , System .getProperty ("java.version" ));
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments