构建 Elasticsearch 源代码(任务:benchmarks:compileJava 失败)

huangapple go评论111阅读模式
英文:

Building elasticsearch from Source (Task :benchmarks:compileJava FAILED)

问题

以下是翻译好的部分:

尝试从源代码构建Elasticsearch。

刚刚安装了OpenJAVA-11-sdk和jre。

下面是`java`和`javac`以及`echo $PATH`的输出。

rajesh@Rajesh-PC:~/elasticsearch$ ./gradlew  assemble
=======================================
Elasticsearch构建Hamster问好!
  Gradle版本        :6.5
  操作系统信息       :Linux 4.15.0-111-generic(amd64)
  JDK版本            :11(JDK)
  JAVA_HOME          :/usr/lib/jvm/java-11-openjdk-amd64
  随机测试种子       :48BEB2A1EC142E2C
  在FIPS 140模式下  :false
=======================================

> Task :build-tools:jar
:build-tools:jar:找到了elasticsearch.enforce-deprecation-use-failures.properties的有效插件描述符,但在jar中未找到实现类org.elasticsearch.gradle.EnforceDeprecationFailuresPlugin。

> Task :benchmarks:compileJava 失败
警告:没有处理器声称拥有这些注释:java.base/java.lang.SuppressWarnings,java.base/java.lang.Override
错误:发现警告并指定了-Werror
1个错误
1个警告

> Task :modules:lang-mustache:compileJava
注意:/home/rajesh/elasticsearch/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java使用或覆盖了已弃用的API。
注意:重新编译时使用-Xlint:deprecation获取详细信息。

失败:任务“:benchmarks:compileJava”的执行失败。
* 出现了什么问题:
  编译失败,请查看编译器错误输出以获取详细信息。

* 尝试:
  使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的洞察。

* 在https://help.gradle.org获取更多帮助

15秒内构建失败
77个可执行任务:17个已执行,60个最新

rajesh@Rajesh-PC:~/elasticsearch$ java -version
openjdk版本"11.0.7" 2020-04-14
OpenJDK运行时环境(构建11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64位服务器VM(构建11.0.7+10-post-Ubuntu-2ubuntu218.04,混合模式,共享)

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


<details>
<summary>英文:</summary>

Trying build Elasticsearch from source.

Just installed OpenJAVA-11-sdk &amp; jre.

below are `java` &amp; `javac` &amp; `echo $PATH` outputs as well.

    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
    =======================================
    
    &gt; 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.
    
    &gt; 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
    
    &gt; 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 &#39;:benchmarks:compileJava&#39;.
    &gt; 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 &quot;11.0.7&quot; 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



</details>


# 答案1
**得分**: 3

**查看错误,似乎存在编译错误,很可能是由于JDK版本引起的,因为您的`JAVA_HOME`指向JDK 11。**

以下是解决此问题的方法:

1. 如果您已经克隆了最新的Elasticsearch源代码,从[https://github.com/elastic/elasticsearch][1],那么要构建Elasticsearch,需要JDK 14。然而,由于Elasticsearch支持JDK 11,因此构建支持使用JDK 14编译并在JDK 11运行时进行测试。

2. 安装JDK 14并将`JAVA_HOME`设置为JDK 14安装的Java主目录后,再次使用以下命令运行Elasticsearch源代码:`./gradlew :run`。

3. 一旦进程完全启动,然后在另一个窗口中运行curl,如下所示:

   `curl -u elastic:password localhost:9200`

要获取详细的解释,请参考[CONTRIBUTING.md][2]


  [1]: https://github.com/elastic/elasticsearch
  [2]: https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase

<details>
<summary>英文:</summary>

**Looking at the errors, it seems like there is a compilation error which is most probably because of the JDK version, as your `JAVA_HOME` is pointing to JDK 11.**

Here are the ways by which you can resolve the issue : 

1. If you have cloned the latest Elasticsearch source code from [https://github.com/elastic/elasticsearch][1], then to build Elasticsearch, JDK 14 is required. However, since Elasticsearch supports JDK 11, the build supports compiling with JDK 14 and testing on a JDK 11 runtime.

2. After installing JDK 14, and setting `JAVA_HOME` pointing to Java home of JDK 14 installation, run Elasticsearch source code with this command again `./gradlew :run`.

3. Once the process is fully started, then run curl in another window like this 

`curl -u elastic:password localhost:9200`

To get a detailed explanation refer this [CONTRIBUTING.md][2]


  [1]: https://github.com/elastic/elasticsearch
  [2]: https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase

</details>



huangapple
  • 本文由 发表于 2020年7月21日 23:17:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/63017715.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定