Brais Gabín Moreira
12/15/2025, 1:02 AMTheGoesen
12/15/2025, 9:09 AMVampire
12/15/2025, 9:12 AMval otherVersionTestRuntimeOnly = configurations.dependencyScope("otherVersionTestRuntimeOnly")
val testRuntimeClasspath by configurations.existing
val otherVersionTestClasspath = configurations.resolvable("otherVersionTestClasspath") {
extendsFrom(otherVersionTestRuntimeOnly.get())
extendsFrom(testRuntimeClasspath.get())
attributes {
attribute(CATEGORY_ATTRIBUTE, objects.named(LIBRARY))
attribute(USAGE_ATTRIBUTE, objects.named(JAVA_RUNTIME))
attribute(LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(JAR))
attribute(BUNDLING_ATTRIBUTE, objects.named(EXTERNAL))
attribute(TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named(STANDARD_JVM))
}
}
dependencies {
implementation("depen:dency:3.0.0")
otherVersionTestRuntimeOnly("depen:dency:4.0.0")
}
testing {
suites {
named<JvmTestSuite>("test") {
val testOtherVersion by targets.registering {
testTask {
classpath = objects.fileCollection().from(
sources.output,
sourceSets.main.map { it.output },
otherVersionTestClasspath
)
}
}
}
}
}
Or something around the linesTheGoesen
12/15/2025, 9:23 AMVampire
12/15/2025, 10:04 AMtarget with one testTask is supported per testSuite.
There are still places that state that, but indeed it works to have multiple `target`s now and the upgrade guide even suggests to use it at one point.
So if you want to run the same tests just with a different environment, I think multiple `target`s is the more idiomatic way.
Also see: https://github.com/gradle/gradle/issues/35708