@@ -167,28 +167,24 @@ class BuildPlugin implements Plugin<Project> {
167
167
project. ext. runtimeJavaVersion = project. rootProject. ext. runtimeJavaVersion
168
168
}
169
169
170
- /* * Finds and enforces JAVA_HOME is set */
171
170
private static String findCompilerJavaHome () {
172
- return findJavaHome(System . getenv(' JAVA_HOME' ), null )
173
- }
174
-
175
- private static String findRuntimeJavaHome (final String compilerJavaHome ) {
176
- return findJavaHome(System . getenv(' RUNTIME_JAVA_HOME' ), compilerJavaHome)
177
- }
178
-
179
- private static String findJavaHome (String maybeJavaHome , String defaultJavaHome ) {
180
- final String javaHome = maybeJavaHome ?: defaultJavaHome
171
+ final String javaHome = System . getenv(' JAVA_HOME' )
181
172
if (javaHome == null ) {
182
173
if (System . getProperty(" idea.active" ) != null || System . getProperty(" eclipse.launcher" ) != null ) {
183
174
// IntelliJ does not set JAVA_HOME, so we use the JDK that Gradle was run with
184
- javaHome = Jvm . current(). javaHome
175
+ return Jvm . current(). javaHome
185
176
} else {
186
- assert false
177
+ throw new GradleException ( " JAVA_HOME must be set to build Elasticsearch " )
187
178
}
188
179
}
189
180
return javaHome
190
181
}
191
182
183
+ private static String findRuntimeJavaHome (final String compilerJavaHome ) {
184
+ assert compilerJavaHome != null
185
+ return System . getenv(' RUNTIME_JAVA_HOME' ) ?: compilerJavaHome
186
+ }
187
+
192
188
/* * Finds printable java version of the given JAVA_HOME */
193
189
private static String findJavaVersionDetails (Project project , String javaHome ) {
194
190
String versionInfoScript = ' print(' +
0 commit comments