ʻWhen automatically generating a script using appassembler-maven-plugin`, I made it possible to set JAVA_HOME in the automatically generated script, so make a note.
First, prepare settings.sh
that describes the export settings of JAVA_HOME as a preliminary preparation.
settings.sh
export JAVA_HOME=/usr/java/jdk1.8.0_152
Next, set assembler so that settings.sh
can be called from the automatically generated script.
Official document has a parameter called ʻenvironmentSetupFileName`, so use this.
pom.xml
・ ・ ・ Omitted ・ ・ ・
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<programs>
<program>
<mainClass>com.fuga.hoge.SampleApp</mainClass>
<name>SampleApp</name>
</program>
</programs>
<binFileExtensions>
<unix>.sh</unix>
</binFileExtensions>
<environmentSetupFileName>settings.sh</environmentSetupFileName>
</configuration>
</plugin>
・ ・ ・ The following is omitted ...
The SampleApp.sh
that is automatically generated when youmvn package
after setting is as follows.
SampleApp.sh
BASEDIR=`dirname $0`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
[ -f "$BASEDIR"/bin/settings.sh ] && . "$BASEDIR"/bin/settings.sh
・ ・ ・ The following is omitted ...
This will load the first created settings.sh
at the beginning of the auto-generated script, so if you set a task to copy settings.sh
under the bin directory after build, it will be in the auto-generated script. You can read the JAVA_HOME settings from.
Recommended Posts