1

I get build errors when using mvn unleash:perform because it tries to use the default Java VM to build the release instead of the one pointed to with JAVA_HOME or the one which was used to start the maven-unleash-plugin.

With -Dunleash.releaseArgs="--debug=true" -X, I can see that the outer Maven uses Java 11 and the inner uses 8.

I tried to fix this with:

mvn unleash:perform -Dunleash.releaseEnvironment="JAVA_HOME=$JAVA_HOME" -X |& tee mvn.log

but that leads to an NPE:

Caused by: java.lang.NullPointerException
    at com.itemis.maven.plugins.unleash.steps.actions.BuildProject.setupInvocationRequest (BuildProject.java:123)
    at com.itemis.maven.plugins.unleash.steps.actions.BuildProject.execute (BuildProject.java:73)

Is changing the default VM in Windows my only option?

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • Is there reason why using an unmaintainend plugin ? – khmarbaise Jul 18 '22 at 19:19
  • For my use cases (stable CI builds) it's better than any alternatives. `mvn deploy` for example has many unresolved bugs like `deployAtEnd` not working reliably. – Aaron Digulla Jul 20 '22 at 13:45
  • First have [you tried the most recent version](https://maven.apache.org/plugins/maven-deploy-plugin/)? And can you offer and example project which shows the problem? Also many unresolved bugs? Hm.. [21](https://cwiki.apache.org/confluence/display/MAVEN/Maven+JIRA+issues+overview) ? Ok... – khmarbaise Jul 20 '22 at 14:10

1 Answers1

0

In my case, the culprit was in .mavenrc (Linux) or %USERPROFILE%\mavenrc_pre.cmd (Windows, also check %USERPROFILE%\mavenrc_pre.bat). There, JAVA_HOME was hardcoded to some specific path.

The fix is to a) only set JAVA_HOME when it has no value and b) to display a warning (with path) when the variable is set. That way, people can't get confused by some silent behavior.

Solution in .mavenrc:

if [[ -z "$JAVA_HOME" ]]; then
    export JAVA_HOME=...
    echo "~/.mavenrc: Setting JAVA_HOME to $JAVA_HOME"
fi

For %USERPROFILE%\mavenrc_pre.cmd, use:

if "%JAVA_HOME%"=="" (
    set JAVA_HOME=...
    echo %USERPROFILE%\mavenrc_pre.cmd: Setting JAVA_HOME to %JAVA_HOME%
)
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820