3

I'm trying to build Elasticsearch from the source. I cloned from the GitHub repo today, and I'm following the instructions under "Building from Source".

Running ./gradlew assemble produces the following error:

...
> Configure project :benchmarks
=======================================
Elasticsearch Build Hamster says Hello!
=======================================
  Gradle Version        : 4.7
  OS Info               : Linux 4.4.0-112-generic (amd64)
  JDK Version           : Oracle Corporation 1.8.0_161 [Java HotSpot(TM) 64-Bit Server VM 25.161-b12]
  JAVA_HOME             : /usr/lib/jvm/java-8-oracle
  Random Testing Seed   : 5554B47DBBCF3CFB
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file '<redacted>/elasticsearch-master/benchmarks/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':benchmarks'.
> Failed to apply plugin [id 'elasticsearch.build']
   > the environment variable JAVA_HOME must be set to a JDK installation directory for Java 1.10 but is [/usr/lib/jvm/java-8-oracle] corresponding to [1.8]
...

Running sudo ./gradlew assemble produces a different error:

FAILURE: Build failed with an exception.

* Where:
Build file '<redacted>/elasticsearch-master/benchmarks/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':benchmarks'.
> Failed to apply plugin [id 'elasticsearch.build']
   > JAVA_HOME must be set to build Elasticsearch

But as far as I can tell, my JAVA_HOME is set:

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

$ sudo echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

$ ls /usr/lib/jvm/java-8-oracle
bin  COPYRIGHT  db  include  javafx-src.zip  jre  lib  LICENSE  man  README.html  release  src.zip  THIRDPARTYLICENSEREADME-JAVAFX.txt  THIRDPARTYLICENSEREADME.txt

Other possibly-useful information:

$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

$ gradle -v

------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------

Build time:   2018-04-18 09:09:12 UTC
Revision:     b9a962bf70638332300e7f810689cb2febbd4a6c

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_161 (Oracle Corporation 25.161-b12)
OS:           Linux 4.4.0-112-generic amd64

I'm running Ubuntu 16.04.

Anyone know how to fix this error (or alternatively, how I can build the latest version of Elasticsearch from the source), without upgrading to Java 10?

4

2 回答 2

6

当 Elasticsearch说它只需要 Java 8时,实际上意味着 Java 8 足以运行Elasticsearch。构建Elasticsearch 完全不同,似乎需要 Java 10(我假设正在使用 Java 10 功能)。所以如果你想从源代码构建 Elasticsearch,你必须升级到 Java 10。

于 2018-05-06T02:26:42.973 回答
1

从源代码构建需要多个 Java 版本用于编译、运行时和测试。构建 Elasticsearch 需要 JDK 13。您必须安装 JDK 13,其中环境变量 JAVA_HOME 引用 Java 主目录的路径以进行 JDK 13 安装。默认情况下,测试使用与 JAVA_HOME 相同的运行时。但是,由于 Elasticsearch 支持 JDK 11,因此构建支持使用 JDK 13 编译和在 JDK 11 运行时上进行测试;为此,请将 RUNTIME_JAVA_HOME 设置为指向 JDK 11 安装的 Java 主目录。请注意,此机制也可用于针对其他 JDK 进行测试,这不仅限于 JDK 11。

注意:还需要有 JAVA8_HOME、JAVA9_HOME、JAVA10_HOME 和 JAVA11_HOME,以及 JAVA12_HOME 才能通过测试。

资料来源:https ://discuss.elastic.co/t/unable-to-build-elasticsearch-from-source-on-mac-could-not-set-unknown-property-excludes/191394和https://github。 com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase 通读 这些对我理解这个构建错误以及为什么它需要不同版本的不同环境变量非常有帮助。希望它可以帮助任何遇到同样问题的人。

于 2019-12-20T18:56:12.243 回答