Skip to content

Commit e4dd661

Browse files
committed
Set JAVA_HOME before forking setup commands
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 6a4c5f3 commit e4dd661

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

553553
/** Adds a task to execute a command to help setup the cluster */
554554
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
555-
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) {
556-
workingDir node.cwd
555+
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
556+
exec.workingDir node.cwd
557+
exec.environment 'JAVA_HOME', node.getJavaHome()
557558
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
558-
executable 'cmd'
559-
args '/C', 'call'
559+
exec.executable 'cmd'
560+
exec.args '/C', 'call'
560561
// On Windows the comma character is considered a parameter separator:
561562
// argument are wrapped in an ExecArgWrapper that escapes commas
562-
args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
563+
exec.args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
563564
} else {
564-
commandLine execArgs
565+
exec.commandLine execArgs
565566
}
566567
}
567568
}

0 commit comments

Comments
 (0)