odpi / egeria

Egeria core
https://egeria-project.org
Apache License 2.0
794 stars 259 forks source link

Building egeria within IntelliJ can fail on new install #1500

Closed planetf1 closed 4 years ago

planetf1 commented 5 years ago

Scenario

This is because the environment within intellij is a little different to the cli

The following fragment should fix for the IDE without breaking other usage - added in the configuration for the javadoc plugin

<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>

This is more noticeable now javadoc is part of the standard lifecycle (from install)

If a global JAVA_HOME is setup, the UI ay inherit and find javadoc, however since IntelliJ supports switching between JDKs as part of the project definition this could end up using the wrong version (or in this case not find it). java.home however is set correctly.. so the above fix provides for consistent results.

planetf1 commented 4 years ago

After some research

➜  egeria git:(master) java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
➜  egeria git:(master) jenv global 11.0
➜  egeria git:(master) echo $JAVA_HOME

➜  egeria git:(master) jenv enable-plugin maven
maven plugin activated
➜  egeria git:(master) jenv enable-plugin export
You may restart your session to activate jenv export plugin echo export plugin activated
➜  egeria git:(master) echo $JAVA_HOME
/Users/jonesn/.jenv/versions/11.0

Whilst in more simple environments, make sure JAVA_HOME is indeed set to a valid JDK, which is best practice in any case

Therefore closing this, but with notes to help anyone else who may hit this issue.

mandy-chessell commented 4 years ago

I am hitting this same problem while setting up a new machine and not seeing how to fix it

mandy-chessell commented 4 years ago
Screenshot 2019-09-08 at 11 12 38

Also seeing this

planetf1 commented 4 years ago

Re-opening as there are clearly issues here -- at a minimum we should have instructions to support developers.

In the case of javadoc failing with JAVA_HOME not found, make sure JAVA_HOME is set to a valid jdk in ~/.bash_profile (if using MacOS bash), ~/.bashrc (if using homebrew bash), ~/.zshrc (if using homebrew zsh) etc. I think catalina will default to zsh for new users. The IDE does not seem to set it, even though the SDK is configured. I will add more notes on this as part of any 'fix'

For dependency resolution, I did not see the above error despite reinstalling intellij / making new fork on 2 machines but I can guess the issue is that both of those dependencies are 'synthetic' - they are actually created, and inserted into a local maven repo, as part of the build process itself. Once 'mvn clean install' has run I expect they will go away. It's not clear how to fix them in the GUI only as maven is the 'authoritative' definition of what to do, but IntelliJ isn't quite following it. A note may be useful to warn new users - can you confirm if it went away after a 'mvn clean install' ?

planetf1 commented 4 years ago

I've raised a request with jetbrains to support setting the right environment within their maven runner. See https://youtrack.jetbrains.com/issue/IDEA-222545 - it seems as if their mvn invocation will use the configured project sdk, but does not export JAVA_HOME. I see this as an IDE deficiency (though can document)

planetf1 commented 4 years ago

updates made (pending pr)