Building v2.3.5 from source fails

Hi,

I am trying to build Elasticsearch v2.3.5 from sources but I am running into build error:

The flow is pretty simple:

$ git clone https://github.com/elastic/elasticsearch.git
$ cd elasticsearch
$ git checkout v2.3.5
$ mvn clean package
// doing $ mvn clean package -DskipTests fails as well

Complete log can be seen here: https://gist.github.com/lukas-vlcek/fa9b33ec54e6d4c7a38a74f97a4b9601

Excerpt:

...
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ elasticsearch ---
[INFO] Compiling 2977 source files to /Users/lvlcek/projects/tmp/elasticsearch/core/target/classes
[WARNING] Unable to autodetect 'javac' path, using 'javac' from the environment.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Build Tools and Resources .......................... SUCCESS [  0.804 s]
[INFO] Rest API Specification ............................. SUCCESS [  0.418 s]
[INFO] Elasticsearch: Parent POM .......................... SUCCESS [  6.334 s]
[INFO] Elasticsearch: Core ................................ FAILURE [  3.591 s]
[INFO] Distribution: Parent POM ........................... SKIPPED
[INFO] Integration Test Package: ZIP ...................... SKIPPED
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.904 s
[INFO] Finished at: 2016-10-03T14:53:31+02:00
[INFO] Final Memory: 66M/1241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project elasticsearch: Compilation failure -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :elasticsearch
...

One interesting thing is that from ES 2.x it seems the tag commits point to -SNAPSHOT versions. See: https://github.com/elastic/elasticsearch/blob/v2.3.5/pom.xml#L9 or https://github.com/elastic/elasticsearch/blob/90f439ff60a3c0f497f91663701e64ccd01edbb4/pom.xml#L9

Why is that? Shall I modify pom.xml files and remove -SNAPSHOT manually before building final version?

May be I am reading something wrong in
https://github.com/elastic/elasticsearch/tree/v2.3.5#building-from-source or https://github.com/elastic/elasticsearch/blob/v2.3.5/TESTING.asciidoc?

Here it works (well, somehow, but the build fails to sign the Debian package, a failure which I expect)

Seems your Maven does not detect a JDK so it emits the message

[WARNING] Unable to autodetect 'javac' path, using 'javac' from the environment.

Maybe setting JAVA_HOME helps?

env | grep JAVA
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home

Yes, that's nasty. I reset the version manually by editing pom.xml.

@jprante good catch, thanks! After I changed from

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
to
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home

the mvn clean package -DskipTests passed without any issues (not even running into issues with Deb package building, interesting you are running into it...).