Skip to content

Commit e24ab08

Browse files
Use always latest toolchain and only run tests in old JVMs
1 parent 06e3158 commit e24ab08

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff 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 }}

build.gradle

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,13 @@ 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-
199
compileJava {
20-
if (javaToolchain != "8") {
21-
options.release = 8
22-
}
10+
options.release = 8
2311
options.compilerArgs.add('-Xlint')
2412
}
2513

2614
compileTestJava {
27-
if (javaToolchain != "8") {
28-
options.release = 8
29-
}
15+
options.release = 8
3016
options.compilerArgs.add('-Xlint')
3117
}
3218

@@ -48,6 +34,17 @@ testing {
4834
suites {
4935
test {
5036
useJUnitJupiter()
37+
targets {
38+
all {
39+
testTask.configure {
40+
javaLauncher.set(
41+
javaToolchains.launcherFor {
42+
languageVersion.set(JavaLanguageVersion.of(System.getenv('TEST_JAVA_TOOLCHAIN')))
43+
}
44+
)
45+
}
46+
}
47+
}
5148
}
5249
}
5350
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package lbmq;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class VersionLoggerTest {
6+
7+
@Test
8+
public void versionLogger() {
9+
String version = System.getProperty("java.version");
10+
System.out.printf("Running in JVM version %s\n", version);
11+
}
12+
}

0 commit comments

Comments
 (0)