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?
In my case, the culprit was in
.mavenrc(Linux) or%USERPROFILE%\mavenrc_pre.cmd(Windows, also check%USERPROFILE%\mavenrc_pre.bat). There,JAVA_HOMEwas hardcoded to some specific path.The fix is to a) only set
JAVA_HOMEwhen 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:For
%USERPROFILE%\mavenrc_pre.cmd, use: