From ebd8bbcffe8f4b0f39ba20e5dd7b0c74f9c0b788 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 10 Nov 2015 14:56:45 -0500 Subject: [PATCH] Get correct jps path on Windows This commit fixes an issue with the jps executable sometimes being available under jps.exe but not jps. --- .../gradle/test/ClusterFormationTasks.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 48613785bae..b1abc1f966d 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -286,9 +286,12 @@ class ClusterFormationTasks { onlyIf { pidFile.exists() } // the pid file won't actually be read until execution time, since the read is wrapped within an inner closure of the GString ext.pid = "${ -> pidFile.getText('UTF-8').trim()}" - File jps = Paths.get(Jvm.current().javaHome.toString(), "bin/jps").toFile() + File jps = getJpsExecutableByName("jps") if (!jps.exists()) { - throw new GradleException("jps executable not found; ensure that you're running Gradle with the JDK rather than the JRE") + jps = getJpsExecutableByName("jps.exe") + if (!jps.exists()) { + throw new GradleException("jps executable not found; ensure that you're running Gradle with the JDK rather than the JRE") + } } commandLine jps, '-l' standardOutput = new ByteArrayOutputStream() @@ -308,6 +311,10 @@ class ClusterFormationTasks { } } + private static File getJpsExecutableByName(String jpsExecutableName) { + return Paths.get(Jvm.current().javaHome.toString(), "bin/" + jpsExecutableName).toFile() + } + /** Adds a task to kill an elasticsearch node with the given pidfile */ static Task configureStopTask(String name, Project project, Object depends, File pidFile) { return project.tasks.create(name: name, type: Exec, dependsOn: depends) {