Skip to content

Commit 2d45f68

Browse files
committed
Set JAVA_HOME before forking setup commands (#29647)
Today when forking setup commands we do not set JAVA_HOME. This means that we might not use a version of Java compatible with the version of Java the command is expecting to run on (for example, 5.6 nodes would expect JDK 8, and this is true even for their setup commands). This commit sets JAVA_HOME when configuring setup command tasks.
1 parent 36c148e commit 2d45f68

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,17 @@ class ClusterFormationTasks {
567567

568568
/** Adds a task to execute a command to help setup the cluster */
569569
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
570-
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) {
571-
workingDir node.cwd
570+
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
571+
exec.workingDir node.cwd
572+
exec.environment 'JAVA_HOME', node.getJavaHome()
572573
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
573-
executable 'cmd'
574-
args '/C', 'call'
574+
exec.executable 'cmd'
575+
exec.args '/C', 'call'
575576
// On Windows the comma character is considered a parameter separator:
576577
// argument are wrapped in an ExecArgWrapper that escapes commas
577-
args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
578+
exec.args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
578579
} else {
579-
commandLine execArgs
580+
exec.commandLine execArgs
580581
}
581582
}
582583
}

0 commit comments

Comments
 (0)