spinscale / cookiecutter-elasticsearch-ingest-processor

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

gradle clean check fails #16

Closed DavidEGx closed 3 years ago

DavidEGx commented 3 years ago

Hi! Trying to run gradle clean check and it is failing miserably...

I have tested it in 3 different environments:

Ubuntu 20.04.2 LTS openjdk version "11.0.11" 2021-04-20 Elastic 7.9.1 OSS Gradle 7.0.2

$ gradle  clean check

FAILURE: Build failed with an exception.

* Where:
Build file '/home/david/ingest-awesome/build.gradle' line: 21

* What went wrong:
A problem occurred evaluating root project 'ingest-awesome'.
> Failed to apply plugin class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin'.
   > Installation is not valid. Original error message: A problem occurred starting process 'command '/usr/lib/jvm/openjdk-11/bin/java''

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

Debian GNU/Linux 10 (buster) openjdk version "11.0.11" 2021-04-20 Elastic 7.9.2 Gradle 4.4.1

gradle clean check
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file '/home/david/ingest-awesome/build.gradle' line: 21

* What went wrong:
A problem occurred evaluating root project 'ingest-awesome'.
> Failed to apply plugin [class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin']
   > Could not create plugin of type 'GlobalBuildInfoPlugin'.
      > org/gradle/jvm/toolchain/internal/JavaInstallationRegistry

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

Debian GNU/Linux 10 (buster) java version "16.0.1" 2021-04-20 Elastic 7.9.2 Gradle 4.4.1

$ gradle clean check

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

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

Any hint? Any particular jvm version I should use? (Not including --stracktrace / --debug to avoid this making this longer)

spinscale commented 3 years ago

you are not supposed to run gradle, but the ./gradlew wrapper, as the each Elasticsearch release is usually only working with a limited set of gradle versions (the wrapper is using automatically the right version, nothing to do on your side).

The gradle versions you listed are years old and should not be used. It might be a good idea to not use the components shipped with your operating system as those are very likely outdated (again the gradle wrapper solves this problem for you with regards to gradle).

DavidEGx commented 3 years ago

Thanks for the quick response. I'm not very familiar with gradle... The gradle in the 1st example is 7.0.2, seems to be relatively recent.

There is no gradlew. Quick search tells me I need to run graddle wrapper to get it, however:

gradle wrapper                                                                 

FAILURE: Build failed with an exception.                      

* Where:
Build file '/home/david/ingest-awesome/build.gradle' line: 21 

* What went wrong:
A problem occurred evaluating root project 'ingest-awesome'.
> Failed to apply plugin class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin'.
   > Installation is not valid. Original error message: A problem occurred starting process 'command '/usr/lib/jvm/openjdk-11/bin/java''

* 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
DavidEGx commented 3 years ago

Oh, ./gradlew... Testing...

DavidEGx commented 3 years ago
  1. Use ./gradlew clean check => error
  2. Install oracle jdk => error
  3. Update alternatives => error
  4. Remove openjdk-11-jdk => success

\o/

Not sure why after 3 kept failing. java -v and javac -v gave me the right Oracle version. However, ./gradlew still used the openjdk version for some reason.

Anyway, time to code something :)

Thanks!

spinscale commented 3 years ago

pro tip, use something like sdkman or asdf to manage your java installations as a user... helps me a lot to switch between java versions

DavidEGx commented 3 years ago

Thanks for the tip. I don't use have since the uni, and that was a long time ago... :D

Finally I made a working demo. However, there were a couple of issues in the process:

  1. It seems to fail when I want to use Elastisearch version 7.10.2:
$ cookiecutter gh:spinscale/cookiecutter-elasticsearch-ingest-processor                                              
You've downloaded /home/david/.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.13.2]: 7.10.2

$ cd ingest-awesome/

$ ./gradlew clean check                                                                                 

FAILURE: Build failed with an exception.                                                                                                         

* Where:                                                                                                                                         
Build file '/home/david/ingest-awesome/build.gradle' line: 21                                                                                    

* What went wrong:                                                                                                                               
A problem occurred evaluating root project 'ingest-awesome'.                                                                                     
> Failed to apply plugin class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin'.                                                            
   > Could not create plugin of type 'GlobalBuildInfoPlugin'.                                                                                    
      > Could not generate a decorated class for type GlobalBuildInfoPlugin.                                                                     
         > org/gradle/jvm/toolchain/JavaInstallation                                                                                             

* 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 insigh

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

BUILD FAILED in 1s                                                                                                                               

It failed with other versions too, not only 7.10.2. Workaround: I used latest version, opened zip file, changed version in plugin-descriptor.properties, save zip.

  1. Error installing: unknown property type
$ /usr/share/elasticsearch/bin/elasticsearch-plugin install file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip 

-> Installing file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip
-> Downloading file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip
[=================================================] 100%   
-> Failed installing file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip
-> Rolling back file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip
-> Rolled back file:////home/david/ingest-awesome-0.0.1-SNAPSHOT.zip
Exception in thread "main" java.lang.IllegalArgumentException: Unknown properties in plugin descriptor: [type]
        at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:233)
        at org.elasticsearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:807)
        at org.elasticsearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:866)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:254)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:224)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
        at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:91)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)

Workaround: Build, opened zip file, remove type in plugin-descriptor.properties, save zip, install.


Not sure if those are bugs or I'm simply doing something stupid. In any case, with those two workarounds it works just fine.

Very nice work btw, glad to have all the scaffolding in place and the unit tests <3

spinscale commented 3 years ago

As there are constant changes in the Elasticsearch plugins/build-tools you need to go back to the commit supported 7.10.2 and go from there... that should make it work