Build: Add nicer error message for pre java 8 (#22911)

This commit adds clearer error message when trying to find the version of java, but
the jjs binary is not found.

closes #22898
This commit is contained in:
Ryan Ernst 2017-02-01 14:07:21 -08:00 committed by GitHub
parent bf439b9cc8
commit 7f59bed87b
1 changed files with 5 additions and 1 deletions

View File

@ -202,11 +202,15 @@ 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') File tmpScript = File.createTempFile('es-gradle-tmp', '.js')
tmpScript.setText(script, 'UTF-8') tmpScript.setText(script, 'UTF-8')
ByteArrayOutputStream output = new ByteArrayOutputStream() ByteArrayOutputStream output = new ByteArrayOutputStream()
ExecResult result = project.exec { ExecResult result = project.exec {
executable = new File(javaHome, 'bin/jjs') executable = jjs
args tmpScript.toString() args tmpScript.toString()
standardOutput = output standardOutput = output
errorOutput = new ByteArrayOutputStream() errorOutput = new ByteArrayOutputStream()