Build: Improve detection of older java versions (#22950)
This change switches to using jrunscript, instead of jjs, for detecting version properties of java, which is available on java versions prior to 8. closes #22898
This commit is contained in:
parent
b2f9f746bb
commit
be0236416b
|
@ -27,6 +27,10 @@ if (GradleVersion.current() < GradleVersion.version('2.13')) {
|
||||||
throw new GradleException('Gradle 2.13+ is required to build elasticsearch')
|
throw new GradleException('Gradle 2.13+ is required to build elasticsearch')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
|
||||||
|
throw new GradleException('Java 1.8 is required to build elasticsearch gradle tools')
|
||||||
|
}
|
||||||
|
|
||||||
if (project == rootProject) {
|
if (project == rootProject) {
|
||||||
// change the build dir used during build init, so that doing a clean
|
// change the build dir used during build init, so that doing a clean
|
||||||
// won't wipe out the buildscript jar
|
// won't wipe out the buildscript jar
|
||||||
|
|
|
@ -202,22 +202,13 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
/** Runs the given javascript using jjs from the jdk, and returns the output */
|
/** Runs the given javascript using jjs from the jdk, and returns the output */
|
||||||
private static String runJavascript(Project project, String javaHome, String script) {
|
private static String runJavascript(Project project, String javaHome, String script) {
|
||||||
File jjs = new File(javaHome, 'bin/jjs')
|
|
||||||
if (jjs.exists() == false) {
|
|
||||||
throw new GradleException("Cannot find jjs binary in java installation at ${javaHome}. At least java 1.8 is required.")
|
|
||||||
}
|
|
||||||
File tmpScript = File.createTempFile('es-gradle-tmp', '.js')
|
|
||||||
tmpScript.setText(script, 'UTF-8')
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream()
|
ByteArrayOutputStream output = new ByteArrayOutputStream()
|
||||||
ExecResult result = project.exec {
|
project.exec {
|
||||||
executable = jjs
|
executable = new File(javaHome, 'bin/jrunscript')
|
||||||
args tmpScript.toString()
|
args '-e', script
|
||||||
standardOutput = output
|
standardOutput = output
|
||||||
errorOutput = new ByteArrayOutputStream()
|
errorOutput = new ByteArrayOutputStream()
|
||||||
ignoreExitValue = true // we do not fail so we can first cleanup the tmp file
|
|
||||||
}
|
}
|
||||||
java.nio.file.Files.delete(tmpScript.toPath())
|
|
||||||
result.assertNormalExitValue()
|
|
||||||
return output.toString('UTF-8').trim()
|
return output.toString('UTF-8').trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue