diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index cb2f99d1..7b3ad8db 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -75,6 +75,7 @@ jobs: -Pplugin.josmCompileVersion=${{ matrix.josm-version}} -Pgraalvm.jdk=jdk${{ matrix.jdk }} -Pgraalvm.platform=${{ env.GRAALVM_PLATFORM }} + -PtestJdkVersion=${{ matrix.jdk }} env: DISPLAY: ":19" diff --git a/build.gradle b/build.gradle index a799e654..1b89bb37 100644 --- a/build.gradle +++ b/build.gradle @@ -334,3 +334,19 @@ publishToGithubRelease { remoteJarName = "scripting.jar" } + +tasks.withType(Test).configureEach { + def testJdkVersion = System.getenv("TEST_JDK_VERSION") ?: "17" + + if (testJdkVersion == "17") { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(17) + } + } else if (testJdkVersion == "21") { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(21) + } + } else { + throw new GradleException("Invalid TEST_JDK_VERSION: ${testJdkVersion}. Must be 17 or 21.") + } +} \ No newline at end of file