Skip to content

Commit 55683d8

Browse files
authored
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]
1 parent a685784 commit 55683d8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,22 @@ class BuildPlugin implements Plugin<Project> {
140140

141141
final GradleVersion minGradle = GradleVersion.version('4.3')
142142
if (currentGradleVersion < minGradle) {
143-
throw new GradleException("${minGradle} or above is required to build elasticsearch")
143+
throw new GradleException("${minGradle} or above is required to build Elasticsearch")
144144
}
145145

146146
// enforce Java version
147147
if (compilerJavaVersionEnum < minimumCompilerVersion) {
148-
throw new GradleException("Java ${minimumCompilerVersion} or above is required to build Elasticsearch")
148+
final String message =
149+
"the environment variable JAVA_HOME must be set to a JDK installation directory for Java ${minimumCompilerVersion}" +
150+
" but is [${compilerJavaHome}] corresponding to [${compilerJavaVersionEnum}]"
151+
throw new GradleException(message)
149152
}
150153

151154
if (runtimeJavaVersionEnum < minimumRuntimeVersion) {
152-
throw new GradleException("Java ${minimumRuntimeVersion} or above is required to run Elasticsearch")
155+
final String message =
156+
"the environment variable RUNTIME_JAVA_HOME must be set to a JDK installation directory for Java ${minimumRuntimeVersion}" +
157+
" but is [${runtimeJavaHome}] corresponding to [${runtimeJavaVersionEnum}]"
158+
throw new GradleException(message)
153159
}
154160

155161
project.rootProject.ext.compilerJavaHome = compilerJavaHome

0 commit comments

Comments
 (0)