4

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?

2 Answers 2

7

When Elasticsearch says that it only requires Java 8, it actually means that Java 8 is sufficient to run Elasticsearch. Building Elasticsearch is completely different and seems to require Java 10 (I would assume Java 10 features are being used). So if you want to build Elasticsearch from the source, you have to upgrade to Java 10.

Sign up to request clarification or add additional context in comments.

1 Comment

The ES author are so radical!
1

Building from source needs multiple java versions for compilation, runtime and testing.JDK 13 is required to build Elasticsearch. You must have a JDK 13 installation with the environment variable JAVA_HOME referencing the path to Java home for your JDK 13 installation. By default, tests use the same runtime as JAVA_HOME. However, since Elasticsearch supports JDK 11, the build supports compiling with JDK 13 and testing on a JDK 11 runtime; to do this, set RUNTIME_JAVA_HOME pointing to the Java home of a JDK 11 installation. Note that this mechanism can be used to test against other JDKs as well, this is not only limited to JDK 11.

Note: It is also required to have JAVA8_HOME, JAVA9_HOME, JAVA10_HOME and JAVA11_HOME, and JAVA12_HOME available so that the tests can pass.

Sources: https://discuss.elastic.co/t/unable-to-build-elasticsearch-from-source-on-mac-could-not-set-unknown-property-excludes/191394 and https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase Reading through these was very helpful for me to understand this build error and why it needs the different env variables for different versions. Hope it helps anyone stumbling on the same issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.