从源代码构建elasticsearch(任务:基准:compileJava FAILED)

时间:2020-07-21 15:17:16

标签: java elasticsearch

尝试从源代码构建Elasticsearch。

只需安装OpenJAVA-11-sdk和jre。

以下是javajavacecho $PATH的输出。

rajesh@Rajesh-PC:~/elasticsearch$ ./gradlew  assemble
=======================================
Elasticsearch Build Hamster says Hello!
  Gradle Version        : 6.5
  OS Info               : Linux 4.15.0-111-generic (amd64)
  JDK Version           : 11 (JDK)
  JAVA_HOME             : /usr/lib/jvm/java-11-openjdk-amd64
  Random Testing Seed   : 48BEB2A1EC142E2C
  In FIPS 140 mode      : false
=======================================

> Task :build-tools:jar
:build-tools:jar: A valid plugin descriptor was found for elasticsearch.enforce-deprecation-use-failures.properties but the implementation class org.elasticsearch.gradle.EnforceDeprecationFailuresPlugin was not found in the jar.

> Task :benchmarks:compileJava FAILED
warning: No processor claimed any of these annotations: java.base/java.lang.SuppressWarnings,java.base/java.lang.Override
error: warnings found and -Werror specified
1 error
1 warning

> Task :modules:lang-mustache:compileJava
Note: /home/rajesh/elasticsearch/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':benchmarks:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 15s
77 actionable tasks: 17 executed, 60 up-to-date

rajesh@Rajesh-PC:~/elasticsearch$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)

rajesh@Rajesh-PC:~/elasticsearch$ javac -version
javac 11.0.7

rajesh@Rajesh-PC:~/elasticsearch$ echo $PATH
/usr/lib/jvm/java-11-openjdk-amd64/bin:/usr/local/cuda-9.0/bin:/home/rajesh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin

1 个答案:

答案 0 :(得分:2)

看着这些错误,似乎是由于JDK版本导致的编译错误,因为您的JAVA_HOME指向JDK 11。

以下是解决问题的方法:

  1. 如果您已从https://github.com/elastic/elasticsearch克隆了最新的Elasticsearch源代码,则为了构建Elasticsearch,需要JDK 14。但是,由于Elasticsearch支持JDK 11,因此该构建支持使用JDK 14进行编译以及在JDK 11运行时进行测试。

  2. 在安装JDK 14并设置JAVA_HOME指向JDK 14安装的Java主页之后,再次使用此命令./gradlew :run运行Elasticsearch源代码。

  3. 一旦过程完全启动,然后在另一个这样的窗口中运行curl

curl -u elastic:password localhost:9200

要获取详细说明,请参阅此CONTRIBUTING.md