From 74bf4b829220d6bd5ae587591365549e677d4841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricky=28=E9=81=93=E7=A6=BB=29?= Date: Mon, 1 Apr 2019 14:00:28 +0800 Subject: [PATCH] If not set JAVA_HOME then use the JDK that Gradle was run with instead (for master) (#40622) Extending the IDE behavior to the cli --- .../org/elasticsearch/gradle/BuildPlugin.groovy | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 97074965a76..8a0e7a05327 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -361,16 +361,8 @@ class BuildPlugin implements Plugin { compilerJavaHome = findJavaHome(compilerJavaProperty) } if (compilerJavaHome == null) { - if (System.getProperty("idea.active") != null || System.getProperty("eclipse.launcher") != null) { - // IntelliJ does not set JAVA_HOME, so we use the JDK that Gradle was run with - return Jvm.current().javaHome - } else { - throw new GradleException( - "JAVA_HOME must be set to build Elasticsearch. " + - "Note that if the variable was just set you might have to run `./gradlew --stop` for " + - "it to be picked up. See https://github.com/elastic/elasticsearch/issues/31399 details." - ) - } + // if JAVA_HOME does not set,so we use the JDK that Gradle was run with. + return Jvm.current().javaHome } return compilerJavaHome }