In the last blog of this series we have added some basic support for IzPack via a module suites build script and an Install script. Now we will edit the scripts to make the installer a little more useful. I don’t now how I could tell the Installer to unzip the file we have added, so we’ll use ant to unzip the distribution file generated by the build-zip task. Afterwards we will edit the IzPack-installer.xml to pack it again.
1. Add a new target “build-unzip” to your modules build.xml and alter the izpack target to depend on it
8<—————————–Publish Entry———————->8
<target name="build-unzip" depends="build,build-launchers,build-zip" description="Unpack a ZIP distribution of the suite.">
<unzip dest="dist" src="dist/${app.name}.zip"/>
</target>
<target name ="izpack" depends="build,build-launchers,build-zip,build-unzip" description="Create an Installer.">
<taskdef name="izpack" classpath="${basedir}/lib/standalone-compiler.jar" classname="com.izforge.izpack.ant.IzPackTask"/>
<echo message="Makes the installer using IzPack"/>
<izpack input="${basedir}/IzPack-install.xml"
output="${basedir}/IzPack-install.jar"
installerType="standard"
basedir="${basedir}"
izPackDir="${basedir}/"/>
</target>
8<—————————————————>8
2. Alter the IzPack-install.xml to pack the directories . Replace the occurrences of <yourapp-name> by your applications name:
8<——————IzPack-install.xml———————-8
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
<info>
<appname><yourapp-name> Installation</appname>
<appversion>1.0 beta</appversion>
<authors>
<author name="Anton Epple" email="epple@genomatix.de"/>
</authors>
<url>http://www.genomatix.de</url>
</info>
<guiprefs width="640" height="480" resizable="no"/>
<locale>
<langpack iso3="eng"/>
</locale>
<resources>
<res id="LicencePanel.licence" src="license.txt"/>
</resources>
<panels>
<panel classname="HelloPanel"/>
<panel classname="LicencePanel"/>
<panel classname="TargetPanel"/>
<panel classname="PacksPanel"/>
<panel classname="InstallPanel"/>
<panel classname="FinishPanel"/>
</panels>
<packs>
<pack name="Base" required="yes">
<description>The base files</description>
<file src="license.txt" targetdir="$INSTALL_PATH"/>
<file src="dist/<yourapp-name>" targetdir="$INSTALL_PATH"/>
<file src="<yourapp-name>.conf" targetdir="$INSTALL_PATH/<yourapp-name>/etc/"/>
<parsable targetfile="$INSTALL_PATH/bibliosphere/etc/<yourapp-name>.conf"/>
</pack>
</packs>
</installation>
8<------------------------------------------------------------8
The new file definition for <yourapp-name>.conf will overwrite the default file. The parsable tag indicates that your <yourapp-name>.conf contains variables that the installer will replace with their values during the installation.
3. Now you need to supply this file (<yourapp-name>.conf) and add it to your module suites root dir:
8<----------------<yourapp-name>.conf-------------------8
# ${HOME} will be replaced by JVM user.home system property
default_userdir="${HOME}/.${APPNAME}/dev"
default_mac_userdir="${HOME}/Library/Application Support/${APPNAME}/dev"
# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="-J-Xms24m -J-Xmx64m -J-Dnetbeans.logger.console=true -J-ea"
# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
jdkhome="$JAVA_HOME"
# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#extra_clusters=
8<------------------------------------------------------------8
The $JAVA_HOME variable will be replaced by IzPack with the current Runtime.
4. Now run the install task. The installer built from this will create the correct directory structure. If you install on your own machine the installed application can be launched from the bin directory.
In the next part of this blog series, we will add a wizard for creating the XML-scripts for the installer.