spinscale / cookiecutter-elasticsearch-ingest-processor

A cookiecutter template for an elasticsearch ingest processor plugin
47 stars 21 forks source link

Unable to create a new processor for Java 1.8. #14

Closed nielsbasjes closed 4 years ago

nielsbasjes commented 4 years ago

As far as I can tell from https://www.elastic.co/support/matrix#matrix_jvm ElasticSearch 7.7.x should still support Java 1.8 so the plugin I have in mind should also work on Java 1.8.

So far I have not been able to let the default plugin as generated by this tool build (at all).

This is what I have tried so far:

When I create a new ingest processor on a system with only JDK 1.8 on it the newly created processor does not build because (as far as I can tell) a needed plugin requires Java 11 or newer.

When I upgrade to JDK 11 I still cannot build the default plugin as it now indicates it needs Java 14.

Reproduction:

I have Ubuntu 16.04 with

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~16.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

$ javac -version
javac 1.8.0_252

I create a new plugin and simply use all default values (the effect is identical if I fill in something 'real'):

niels@committer:~/tmp$ ~/.local/bin/cookiecutter gh:spinscale/cookiecutter-elasticsearch-ingest-processor
You've downloaded /home/niels/.cookiecutters/cookiecutter-elasticsearch-ingest-processor before. Is it okay to delete and re-download it? [yes]: 
processor_type [awesome]: 
package_dir [awesome]: 
description [Ingest processor that is doing something awesome]: 
developer_name [YOUR REAL NAME]: 
elasticsearch_version [7.7.0]: 

When i build it I see

niels@committer:~/tmp$ cd ingest-awesome/
niels@committer:~/tmp/ingest-awesome$ ./gradlew 

FAILURE: Build failed with an exception.

* Where:
Build file '/home/niels/tmp/ingest-awesome/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'ingest-awesome'.
> Failed to apply plugin [id 'elasticsearch.esplugin']
   > Could not create plugin of type 'PluginBuildPlugin'.
      > Could not generate a decorated class for type PluginBuildPlugin.
         > org/elasticsearch/gradle/plugin/PluginPropertiesExtension has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0

* 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 700ms

Since class file version 54 is Java 11+ I install OpenJDK 11 as described here https://askubuntu.com/questions/1203898/package-openjdk-11-jdk-has-no-installation-candidate

niels@committer:~/tmp/ingest-awesome$ java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-2ubuntu116.04)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-2ubuntu116.04, mixed mode, sharing)
niels@committer:~/tmp/ingest-awesome$ javac -version
javac 11.0.5
niels@committer:~/tmp/ingest-awesome$ 

and I try to rebuild

niels@committer:~/tmp/ingest-awesome$ export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
niels@committer:~/tmp/ingest-awesome$ ./gradlew --stop
Stopping Daemon(s)
1 Daemon stopped
niels@committer:~/tmp/ingest-awesome$ ./gradlew 
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file '/home/niels/tmp/ingest-awesome/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'ingest-awesome'.
> Failed to apply plugin [class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin']
   > The compiler java.home must be set to a JDK installation directory for Java 14 but is [/usr/lib/jvm/java-1.11.0-openjdk-amd64] corresponding to [11]

* 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 3s

Alternative to the JAVA_HOME environment variable I have tried setting it in a gradle.properties file but the error stays the same.

niels@committer:~/tmp/ingest-awesome$ cat gradle.properties 
org.gradle.java.home=/usr/lib/jvm/java-1.11.0-openjdk-amd64

I have not yet been able to figure out where the "Java 14" error comes from. I do not have installed Java 14 and I prefer not to install it at all (for me "too new" and not "LTS")

As you can understand: I'm stuck.

What do I need to change to make this basic "dummy" plugin build?

nielsbasjes commented 4 years ago

As a test I cloned one of your other projects https://github.com/spinscale/elasticsearch-ingest-langdetect and simply doing a ./gradlew results in the exact same error.

nielsbasjes commented 4 years ago

I may be onto the root cause. It seems the build-tools from ES 7.7.0 require Java 14 to compile anything. https://github.com/elastic/elasticsearch/pull/54696

Yet the https://www.elastic.co/support/matrix#matrix_jvm states runtime 1.8 is still supported and Java 9, Java 10, Java 12, and Java 13 are short term releases. We advise against using them unless you're prepared to handle the fast release cadence this imposes.

spinscale commented 4 years ago

first, this is a community plugin, so it is not affected by the official support matrix. I try to be as compatible as possible all the time though.

However, I think you are confusing the java version required to build a plugin and the java version required to run a plugin, as you correctly noted in your last statement.

Elasticsearch 7.7 also requires a very recent java to build, however you can run it in java 8 as well. As this is using the build-tools from Elasticsearch, the java version build requirements are exactly the same than for Elasticsearch 7.7.

Hope that clears it up. Feel free to ask for more details.

Are we good to close this one?

nielsbasjes commented 4 years ago

Yes, thanks for your explanation.