Skip to content

Commit 35a8b88

Browse files
dependabot[bot]GitHub CopilotCopilot
authored
Fix build with JUnit 6: set Java 17 on test configurations (#310)
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: GitHub Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 053fbef commit 35a8b88

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.api.attributes.java.TargetJvmVersion
2+
13
plugins {
24
id 'eclipse'
35
id 'java-gradle-plugin'
@@ -31,7 +33,7 @@ configurations {
3133
compile.extendsFrom plugin
3234
}
3335

34-
def jUnitVersion = '5.14.0'
36+
def jUnitVersion = '6.0.1'
3537

3638
dependencies {
3739
implementation gradleApi()
@@ -72,7 +74,21 @@ configurations {
7274
}
7375
}
7476

77+
configurations.testCompileClasspath {
78+
attributes {
79+
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
80+
}
81+
}
82+
configurations.testRuntimeClasspath {
83+
attributes {
84+
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
85+
}
86+
}
87+
7588
test {
89+
javaLauncher = javaToolchains.launcherFor {
90+
languageVersion = JavaLanguageVersion.of(17)
91+
}
7692
useJUnitPlatform()
7793

7894
testLogging {

0 commit comments

Comments
 (0)