Clarify how to set compiler and runtime JDKs (#29101)

This commit enhances the error messages reported when JAVA_HOME and
RUNTIME_JAVA_HOME are not correctly set to point towards the minimum
compiler and minimum runtime JDKs that are expected by the builds. The
previous error message would say:

Java 1.9 or above is required to build Elasticsearch

which is confusing if the user does have a JDK 9 installation and is
even the version that they have on their path yet they have JAVA_HOME
pointing to another JDK installation. The error message reported after
this change is:

the environment variable JAVA_HOME must be set to a JDK installation directory for Java 1.9 but is [/usr/java/jdk-8] corresponding to [1.8]
This commit is contained in:
Jason Tedor 2018-03-15 20:58:37 -04:00 committed by GitHub
parent a685784cea
commit 55683d89c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -140,16 +140,22 @@ class BuildPlugin implements Plugin<Project> {
final GradleVersion minGradle = GradleVersion.version('4.3')
if (currentGradleVersion < minGradle) {
throw new GradleException("${minGradle} or above is required to build elasticsearch")
throw new GradleException("${minGradle} or above is required to build Elasticsearch")
}
// enforce Java version
if (compilerJavaVersionEnum < minimumCompilerVersion) {
throw new GradleException("Java ${minimumCompilerVersion} or above is required to build Elasticsearch")
final String message =
"the environment variable JAVA_HOME must be set to a JDK installation directory for Java ${minimumCompilerVersion}" +
" but is [${compilerJavaHome}] corresponding to [${compilerJavaVersionEnum}]"
throw new GradleException(message)
}
if (runtimeJavaVersionEnum < minimumRuntimeVersion) {
throw new GradleException("Java ${minimumRuntimeVersion} or above is required to run Elasticsearch")
final String message =
"the environment variable RUNTIME_JAVA_HOME must be set to a JDK installation directory for Java ${minimumRuntimeVersion}" +
" but is [${runtimeJavaHome}] corresponding to [${runtimeJavaVersionEnum}]"
throw new GradleException(message)
}
project.rootProject.ext.compilerJavaHome = compilerJavaHome