John
02/21/2025, 5:13 PMtargets {
all {
testTask.configure {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
}
to run tests on a different JDK, but what if I want to compile my tests on that JDK too (but only for this suite). or at least have the runtime classpath configured for it. My use case is that i have code that compiles on java 11, but i want a test suite that pulls in some additional dependencies, which require 17 (spring boot 3), so I need to avoid the
Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 11
errorJohn
02/21/2025, 5:58 PMconfigurations.named("mySuiteRuntimeClasspath"){
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
}
configurations.named("mySuiteCompileClasspath"){
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
}John
02/21/2025, 6:10 PMtasks.named<JavaCompile>("compileBoot3TestJava"){
javaCompiler.set(javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
})
}
tasks.named<KotlinCompile>("compileBoot3TestKotlin"){
kotlinJavaToolchain.toolchain.use(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
})
}
worksVampire
02/21/2025, 6:44 PM