Slackbot
12/02/2023, 6:26 PMThomas Broyer
12/02/2023, 7:55 PMThomas Broyer
12/02/2023, 7:59 PMThor Rognan
12/02/2023, 9:18 PMVampire
12/03/2023, 12:02 PMwithJavaVersion or withToolchain is missing, but you can do it.
Make the SUT build have a gradle.properties file where the property org.gradle.java.home is set to what the test should run with and it works as expected.
I calculate the values for these by using javaToolchains extension to get the toolchains provisioned, then set system properties on the test task with the path, then read those system properties in the test to generate the appropriate gradle.properties.
Works like a charm here.Thomas Broyer
12/03/2023, 12:56 PMThor Rognan
12/03/2023, 6:41 PMorg.gradle.java.installations.auto-download=true in the test specific gradle.properties file in some way to get all the required JDKs available for the tests?Thomas Broyer
12/03/2023, 7:52 PM~/.gradle/gradle.properties), only to run the test task with the appropriate JDK. I have no idea how/when Gradle will attempt to download them (and don't want to know)Thor Rognan
12/03/2023, 7:58 PMThor Rognan
12/03/2023, 8:06 PMThor Rognan
12/03/2023, 8:07 PMThomas Broyer
12/03/2023, 8:08 PMVampire
12/03/2023, 8:08 PMVampire
12/03/2023, 8:13 PMtesting {
suites {
val functionalTest by registering(JvmTestSuite::class) {
targets.configureEach {
testTask {
val java17Home = javaToolchains
.launcherFor { languageVersion.set(JavaLanguageVersion.of(17)) }
.get()
.metadata
.installationPath
.asFile
.absolutePath
systemProperty("java17Home", java17Home)
}
}
}
}
}
and in the test code
def 'test with Java 17'() {
given:
def java17Home = System.getProperty('java17Home')
assert java17Home
and:
gradleProperties << """
org.gradle.java.home = ${java17Home.replace($/\/$, $/\\/$)}
""".stripIndent(true)
when:
runner
.withArguments('help')
.build()
then:
// ...
}Vampire
12/03/2023, 8:15 PMorg.gradle.java.installations.auto-download=true in the test-specific properties is not needed.
It would even not be relevant, as you want to run the SUT test with a specific Java version I understood, not just use a specific toolchain within the SUT build.
The latter would be no problem at all and would probably not have lead to this discussion. šThor Rognan
12/05/2023, 2:26 AMGradleRunner.withDebug(true) , which causes TestKit to run without a daemon, or the daemon will terminate the build with The newly created daemon process has a different context than expected..
My java-home for jdk8 has symlinks to the actual content. I.e. /path/to/java/zulu-8.72.0.17 has symlinks to bin, jre, etc, whereas the actual directories are in a subdirectory. I tried putting org.gradle.daemon=false in the properties file along with the java-home, but I couldn't get it to work consistently with Gradle 6.7.
Other than that everything worked just as expected.
Thanks for all the help guys! šāāļøVampire
12/05/2023, 3:11 AM