Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: temurin
# The target JDK is used to build, the latest one to run Gradle itself (we cannot use Java 8 for Gradle)
# Being in the last position, the latest JDK is used by default to build, the version from the matrix is made
# available to run the tests, to check compatibility.
java-version: |
${{ matrix.java-version }}
21

# delete gradle.properties in Java 8 because it contains a then-unsupported JVM argument: --add-exports
- run: rm gradle.properties
if: ${{ matrix.java-version == 8 }}

- run: ./gradlew assemble check --info
env:
JAVA_TOOLCHAIN: ${{ matrix.java-version }}
TEST_JAVA_TOOLCHAIN: ${{ matrix.java-version }}
35 changes: 17 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@ plugins {
id "com.diffplug.spotless" version "7.2.1"
}

var javaToolchain = System.getenv('JAVA_TOOLCHAIN')

java {
if (javaToolchain != null) {
toolchain {
languageVersion = JavaLanguageVersion.of(javaToolchain)
}
}
}

compileJava {
if (javaToolchain != "8") {
options.release = 8
}
options.compilerArgs.add('-Xlint')
options.release = 8
// for some reason javac warns the previous option, disabling
options.compilerArgs.add('-Xlint:all,-options')
}

compileTestJava {
if (javaToolchain != "8") {
options.release = 8
}
options.compilerArgs.add('-Xlint')
options.release = 8
// for some reason javac warns the previous option, disabling
options.compilerArgs.add('-Xlint:all,-options')
}

repositories {
Expand All @@ -48,6 +36,17 @@ testing {
suites {
test {
useJUnitJupiter()
targets {
all {
testTask.configure {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(System.getenv('TEST_JAVA_TOOLCHAIN')))
}
)
}
}
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/lbmq/VersionLoggerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package lbmq;

import org.junit.jupiter.api.Test;

/**
* Not really a test, but a way of confirming that tests are running with the intended JVM version.
*/
public class VersionLoggerTest {

@Test
public void versionLogger() {
System.out.printf("Running in JVM version %s\n", System.getProperty("java.version"));
}
}