Skip to content

Commit b952a99

Browse files
authored
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 7a74b19 commit b952a99

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
@@ -563,16 +563,17 @@ class ClusterFormationTasks {
563563

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

0 commit comments

Comments
 (0)