4

I need to set my JAVA_HOME/ JAVACMD for the maven appassembler so that it is set in the script and override the system JAVA_HOME property when running the script.

I see how I can do this for the jsw settings (set wrapper.java.command) but that doesnt seem to be the correct this for the basic program.

How can I do this?

The appassembler man pages didn't really help. http://mojo.codehaus.org/appassembler/index.html

Josh
  • 818
  • 2
  • 16
  • 27
  • Is it not enough to just run the setup script like so `JAVA_HOME=/path/to/jdk script.sh`? This will override the system default and is a bit better than hardcoding the path in the script itself, since you can easily use it with different JVM locations. – paul-g Oct 20 '14 at 19:50
  • I would rather it was inside the script as we are in the process of upgrading to java 1.8 from 1.7 and are not ready to be upgrading the java home and potentially upgrading all of our apps – Josh Oct 21 '14 at 09:24
  • But that command will only override JAVA_HOME while you run `script.sh`. It will not override it system wide... – paul-g Oct 21 '14 at 09:29
  • agreed. but we have users whom wont think to run the export command first. If it is not possible then there is no alternative... – Josh Oct 21 '14 at 09:36
  • I see. Could you provide your own wrapper script that just sets that variable and calls the maven appsembler script? – paul-g Oct 21 '14 at 09:40

1 Answers1

0

I managed to solve this problem with the windowsScriptTemplate parameter. I copied the windowsBinTemplate file from Appassembler source code and placed it in a appassembler directory inside my project directory, edited it so that my JAVACMD variable had the value I wanted, and configured my pom.xml accodingly.

In the original script, I simply changed line 53 to what I needed, like that:

if "%JAVACMD%"=="" set JAVACMD="%BASEDIR%"\jdk-13.0.1\bin\java

Here is my pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>appassembler-maven-plugin</artifactId>
    <executions>
        ...
    </executions>
    <configuration>
        <windowsScriptTemplate>${basedir}/appassembler/windowsBinTemplate</windowsScriptTemplate>
        ...
    </configuration>
</plugin>
Ramiro
  • 698
  • 6
  • 21