Skip to content

Commit 864d6cf

Browse files
committed
Configure org.gradle.java.installations.fromEnv for test builds
Signed-off-by: Daniel Clausen <dclausen@gradle.com>
1 parent 1fb7620 commit 864d6cf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugin/src/test/groovy/org/gradle/testretry/AbstractPluginFuncTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,23 @@ abstract class AbstractPluginFuncTest extends Specification implements TestFrame
3737
@Rule
3838
TemporaryFolder testProjectDir = new TemporaryFolder()
3939

40+
File gradleProperties
41+
4042
File settingsFile
4143

4244
File buildFile
4345

4446
def setup() {
47+
gradleProperties = testProjectDir.newFile('gradle.properties')
48+
testJavaToolchainVersion().ifPresent { major ->
49+
// When a specific Java version is specified that tests should configure,
50+
// we have to configure the build to allow finding the version via an env variable.
51+
def expectedEnvVar = "JDK${major}"
52+
assert (System.getenv(expectedEnvVar) != null) : "Test toolchain version is configured but env var ${expectedEnvVar} is missing!"
53+
54+
gradleProperties << "org.gradle.java.installations.fromEnv=${expectedEnvVar}"
55+
}
56+
4557
settingsFile = testProjectDir.newFile('settings.gradle')
4658
settingsFile << "rootProject.name = 'hello-world'"
4759
buildFile = testProjectDir.newFile('build.gradle')

0 commit comments

Comments
 (0)