From 6dca7e632e030a5fc7e56c43bd6a63c5e5543d3d Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Fri, 24 Apr 2026 10:48:52 +0100 Subject: [PATCH] Fix build with JUnit 6: set Java 17 on test configurations JUnit 6.0.1 requires Java 17+. Rather than bumping the plugin's sourceCompatibility (which would break users on Java 11-16), directly override the org.gradle.jvm.version attribute on testCompileClasspath and testRuntimeClasspath to 17. This allows Gradle variant resolution to accept JUnit 6 artifacts while keeping the plugin bytecode compatible with Java 11. The test task already uses a Java 17 JVM via the javaLauncher toolchain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build.gradle | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f1ee3e5..5e40093 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.api.attributes.java.TargetJvmVersion + plugins { id 'eclipse' id 'java-gradle-plugin' @@ -31,7 +33,7 @@ configurations { compile.extendsFrom plugin } -def jUnitVersion = '5.14.0' +def jUnitVersion = '6.0.1' dependencies { implementation gradleApi() @@ -72,7 +74,21 @@ configurations { } } +configurations.testCompileClasspath { + attributes { + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + } +} +configurations.testRuntimeClasspath { + attributes { + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + } +} + test { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(17) + } useJUnitPlatform() testLogging {