My IzPack installation script that I use for my installer has changed tremendously to integrate easily with our production system which needed installation environment properties defined in a properties file instead of being supplied by the customer. With this system, the client defines all the variables in the properties file and supply the packed zip file at installation time. The Zip file is created by us from a Technical questionnaire(TQ) given to the client at the project initiation phase. This way, we control all the parameters and customer does not make any input during the installation. We also have a Java Service wrapper file to install it automatically as a service. The file is parsed by the IzPack script to insert all the variables. We currently use this to integrate into more than ten different LLPG and NLPG systems.
CHANGE THE PATHS TO SUIT YOUR ENVIRONMENT
So here I will post my scripts: build.xml
Ant Integration Task
<target name="build-dev-installer" depends="deploy_zip,create-dev-installer">
</target>
<target name="create-dev-installer" description="Create Windows Installer">
<echo message=" "/>
<echo message="Setting property and task for installer creation" />
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar"/>
<echo message=" "/>
<echo message="Preparing ...." />
<delete dir="${packaging.dir}"/>
<mkdir dir="${packaging.dir}" />
<mkdir dir="${packaging.build.dir}" />
<copy todir="${deploy.dir}" file="${catalina.source}" failonerror="true"/>
<copy todir="${packaging.dir}">
<fileset dir="installer">
<include name="nizpack.xml"/>
<include name="launch4jConfig.xml"/>
<include name="launcher.ini"/>
</fileset>
<fileset dir="src/web">
<include name="lalpac.ico"/>
<include name="lal_Logo3d.gif"/>
</fileset>
</copy>
<replace dir="${packaging.dir}">
<include name="*.xml"/>
<replacefilter token="[APP-NAME]" value="${app.name}" />
<replacefilter token="[BUILD-VERSION]" value="${build.version}" />
<replacefilter token="[APP-VERSION]" value="${app.version}" />
<replacefilter token="[APP-PATH]" value="${app.subpath}" />
<replacefilter token="[JAVA-VERSION]" value="${java.version.minimum}" />
<replacefilter token="[APP-URL]" value="${app.url}" />
<replacefilter token="[APP-AUTHOR]" value="${app.author}" />
<replacefilter token="[APP-CONTACT]" value="${app.contact}" />
<replacefilter token="[CATALINA-VERSION]" value="${catalina.version}" />
<replacefilter token="[CATALINA-SOURCE]" value="${catalina.source}" />
<replacefilter token="[FILE-NAME]" value="${izpack-installer}" />
<replacefilter token="[DEPLOY]" value="${deploy.win}" />
<replacefilter token="[PACKAGING_BUILD]" value="${packaging.build.dir}" />
<replacefilter token="[COPY_RIGHT]" value="${app.copyright}" />
<replacefilter token="[ANT_HOME]" value="${ant.dir}" />
<replacefilter token="[PACK_SOURCE]" value="${deploy.dir}" />
<replacefilter token="[PKG_DEV]" value="${deploy.dir}" />
</replace>
<echo message=" "/>
<echo message="Makes the installer using IzPack to ${izpack-installer}"/>
<izpack input="${basedir}/${packaging.dir}/nizpack.xml"
output="${deploy.dir}/${izpack-installer}"
installerType="standard"
basedir="${basedir}"
izPackDir="${izpack.dir}/"/>
<echo message=" Creating Launch4j Pack"/>
<mkdir dir="${ms.install.dev}/${ms.package.name}" />
<launch4j configFile="${packaging.dir}/launch4jConfig.xml"/>
<echo message=" "/>
<echo message="cleaning and finalizing release" />
<delete dir="${packaging.dir}"/>
</target>
The IzPack Script: nizpack.zml
<installation version="1.0">
<info>
<appname>[APP-NAME]</appname>
<appversion>[APP-VERSION]</appversion>
<appsubpath>[APP-PATH]</appsubpath>
<javaversion>[JAVA-VERSION]</javaversion>
<summarylogfilepath>$INSTALL_PATH/installinfo/Summary.htm</summarylogfilepath>
<url>[APP-URL]</url>
<authors>
<author name="[APP-AUTHOR]" email="[APP-CONTACT]"/>
</authors>
</info>
<guiprefs width="700" height="530" resizable="yes">
<modifier key="useLabelIcons" value="no"/>
<modifier key="useHeadingPanel" value="yes"/>
<modifier key="headingLineCount" value="1"/>
<modifier key="headingFontSize" value="2"/>
<modifier key="useFlags" value="no"/>
<modifier key="langDisplayType" value="native"/>
<modifier key="allYGap" value="8"/>
<modifier key="allXGap" value="4"/>
<modifier key="labelGap" value="2"/>
<modifier key="headingPanelCounter" value="progressbar"/>
<modifier key="headingPanelCounterPos" value="inNavigationPanel"/>
</guiprefs>
<locale>
<langpack iso3="eng"/>
</locale>
<native name="ShellLink.dll" type="izpack">
<os family="windows"/>
</native>
<native name="COIOSHelper.dll" stage="both" type="3rdparty">
<os family="windows"/>
</native>
<listeners>
<listener installer="RegistryInstallerListener" uninstaller="RegistryUninstallerListener">
<os family="windows"/>
</listener>
<listener installer="AntActionInstallerListener" uninstaller="AntActionUninstallerListener"/>
</listeners>
<!-- Conditions -->
<conditions>
<condition type="variable" id="condition.qas.gbr">
<name>connector.type</name>
<value>QAS_GBR_V6</value>
</condition>
<condition type="variable" id="condition.qas.lpg">
<name>connector.type</name>
<value>QAS_LPG_V6</value>
</condition>
<condition type="variable" id="start.addresshub">
<name>start_addresshub</name>
<value>true</value>
</condition>
<condition type="variable" id="condition.mvm">
<name>connector.type</name>
<value>MVM</value>
</condition>
<condition type="variable" id="condition.sql">
<name>connector.type</name>
<value>SQL</value>
</condition>
</conditions>
<!-- Variables -->
<dynamicvariables>
<variable name="TOMCAT_HOME" value="$INSTALL_PATH\$TOMCAT_VER"/>
<variable name="JDK_HOME" value="${jdk.home}"/>
<variable name="TEMP_HOME" value="$INSTALL_PATH\temp"/>
<variable name="JDKPathPanel.minVersion" value="1.5"/>
<variable name="JDKPathPanel.maxVersion" value="1.5"/>
<variable name="JDKPathPanel.skipIfValid" value="yes"/>
<variable name="ADDRESSHUB_CONF_FILE" value="${addresshub.file}"/>
</dynamicvariables>
<variables>
<variable name="TOMCAT_VER" value="[CATALINA-VERSION]"/>
</variables>
<resources>
<res src="installer/ProcessPanel.Spec.xml" id="ProcessPanel.Spec.xml"/>
<!-- res src="installer/shortcutSpec.xml" id="shortcutSpec.xml"/ -->
<res src="installer/UserInput.Spec.xml" id="userInputSpec.xml" />
<res src="installer/antActionsSpec.xml" id="AntActionsSpec.xml" />
<res id="Heading.image" src="src/web/lalpac-logo-cms.png"/>
</resources>
<panels>
<panel classname="HelloPanel"/>
<panel classname="TargetPanel"/>
<panel classname="UserInputPanel" id="Connector.Select"/>
<panel classname="InstallPanel"/>
<!-- panel classname="ShortcutPanel"/ -->
<panel classname="SimpleFinishPanel"/>
</panels>
<packs>
<pack name="Installing Selected Packages" required="yes">
<description>LalPac Addresshub core installation.</description>
<file targetdir="$INSTALL_PATH" src="[PACK_SOURCE]/[CATALINA-VERSION].zip" unpack="true"/>
<file targetdir="$INSTALL_PATH/[CATALINA-VERSION]" src="[PACK_SOURCE]/lalpac-tomcat-customised.zip" unpack="true"/>
<file targetdir="$INSTALL_PATH/[CATALINA-VERSION]" src="[PACK_SOURCE]/lalpac-tomcat-nt-service.zip" unpack="true"/>
<singlefile target="$INSTALL_PATH/temp/installer_scripts.xml" src="installer/installer_scripts.xml"/>
<parsable type="plain" parse="yes" targetfile="$INSTALL_PATH/[CATALINA-VERSION]/conf/wrapper.conf"/>
<parsable type="at" targetfile="$INSTALL_PATH/temp/installer_scripts.xml" parse="yes"/>
<file targetdir="$INSTALL_PATH/temp" src="[PACK_SOURCE]/lalpac-tomcat.zip" unpack="true"/>
<singlefile target="$INSTALL_PATH/temp/web.xml" src="src/conf/dist.web_1.xml"/>
<singlefile target="$INSTALL_PATH/temp/server.xml" src="src/conf/dist.server.win.xml"/>
<singlefile target="$INSTALL_PATH/temp/qas/QAWSERVE_GBR.INI" src="src/conf/qas/dist.QAWSERVE_GBR.INI"/>
<singlefile target="$INSTALL_PATH/temp/qas/QAWSERVE_LPG.INI" src="src/conf/qas/dist.QAWSERVE_LPG.INI"/>
<singlefile target="$INSTALL_PATH/temp/qas/QAWORLD.INI" src="src/conf/qas/QAWORLD_dist.INI"/>
<parsable type="plain" parse="yes" targetfile="$INSTALL_PATH/temp/qas/QAWORLD.INI"/>
</pack>
</packs>
<jar src="[ANT_HOME]/lib/ant.jar" stage="both"/>
<jar src="[ANT_HOME]/lib/ant-launcher.jar" stage="both"/>
</installation>
The Packing Time Ant Integration Script which invokes the ant script: AntActionsSpec.xml
<?xml version="1.0" encoding="UTF-8"?> <antactions> <pack name="Installing Selected Packages"> <antcall order="afterpacks" buildfile="$TEMP_HOME/installer_scripts.xml" logfile="$TEMP_HOME/ant-log.txt" verbose="yes"> <property name="extract_from" value="$ADDRESSHUB_CONF_FILE"/> <property name="extract_to" value="$TEMP_HOME"/> <target name="extract"/> </antcall> <antcall order="afterpacks" buildfile="$TEMP_HOME/installer_scripts.xml" logfile="$TEMP_HOME/ant-log.txt" verbose="yes"> <property name="extract_to" value="$TEMP_HOME"/> <property name="tomcat.home" value="$TOMCAT_HOME"/> <property name="install.path" value="$INSTALL_PATH"/> <target name="setup"/> </antcall> <antcall order="afterpacks" buildfile="$TEMP_HOME/installer_scripts.xml" logfile="$TEMP_HOME/ant-log.txt" verbose="yes"> <property name="extract_to" value="$TEMP_HOME"/> <property name="tomcat.home" value="$TOMCAT_HOME"/> <property name="install.path" value="$INSTALL_PATH"/> <target name="ConnectorConfig"/> </antcall> <antcall order="afterpacks" uninstall_order="beforedeletion" buildfile="$TEMP_HOME/installer_scripts.xml"> <target name="InstallService"/> <uninstall_target name="UninstallService"/> </antcall> </pack> </antactions>
The actual Ant script that is executed: installer_scripts.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="InstallerScripts" basedir=".">
<!-- This target extracts the Config pack received at install time-->
<target name="extract" description="This target extracts the Config pack received at install time">
<!-- TODO define script. See Help menu or http://ant.apache.org/ -->
<unzip src="${extract_from}" dest="${extract_to}"/>
</target>
<!-- This target sets up the core addresshub without any specific Connector Configurations-->
<target name="setup" description="This target sets up the core addresshub without any specific Connector Configurations">
<!-- Set The properties-->
<property file="${extract_to}/install.properties"/>
<!-- Replace the placeholders-->
<replace dir="${install.path}/temp">
<include name="*.xml"/>
<replacefilter token="[START-PORT]" value="${port.startup}" />
<replacefilter token="[SHUTDOWN-PORT]" value="${port.shutdown}" />
<replacefilter token="[LOCALHOST]" value="${server.name}" />
</replace>
<!-- Replace the webapps folder-->
<delete dir="@TOMCAT_HOME/webapps" failonerror="true">
</delete>
<echo message="webapps deleted" />
<mkdir dir="@TOMCAT_HOME/webapps"/>
<copy todir="@TOMCAT_HOME/webapps" failonerror="true" verbose="true">
<fileset dir="@TEMP_HOME/webapps" >
</fileset>
</copy>
<!-- Replace the Addresshub properties -->
<delete file="@TOMCAT_HOME/webapps/lalpac-addresshub/WEB-INF/classes/addresshub.properties"/>
<copy file="${extract_to}/addresshub.properties" tofile="${tomcat.home}\webapps\lalpac-addresshub\WEB-INF\classes\addresshub.properties" verbose="true" failonerror="true" />
<!-- Replace the Web.xml properties -->
<delete file="@TOMCAT_HOME/webapps/lalpac-addresshub/WEB-INF/web.xml"/>
<copy file="@TEMP_HOME/web.xml" tofile="${tomcat.home}\webapps\lalpac-addresshub\WEB-INF\web.xml" verbose="true" failonerror="true" />
<!-- Replace the Tomcat Configurations -->
<copy file="@TEMP_HOME/server.xml" tofile="@TOMCAT_HOME/conf/server.xml" failonerror="true" />
<!-- copy file="@TEMP_HOME/conf/catalina.policy" tofile="@TOMCAT_HOME/conf/catalina.policy" failonerror="true" / -->
<!-- copy file="@TEMP_HOME/conf/wrapper.conf" tofile="@TOMCAT_HOME/conf/wrapper.conf" failonerror="true" / -->
</target>
<target name="ConnectorConfig">
<property file="${extract_to}/install.properties"/>
<antcall target="qas.conf"/>
</target>
<condition property="qas.lpg.installed">
<equals arg1="${install.type}" arg2="qas_lpg" casesensitive="false"/>
</condition>
<target name="qas.conf" if="qas.lpg.installed">
<copy todir="@TOMCAT_HOME\shared\lib" >
<fileset dir="//${qas.api.home}" >
<include name="qalcl.dat"/>
<include name="qalicn.ini"/>
<include name="qaupied.dll"/>
<include name="qaupied.044"/>
</fileset>
</copy>
<copy file="@TEMP_HOME/qas/QAWSERVE_LPG.INI" tofile="@TOMCAT_HOME/shared/lib/QAWSERVE.INI" failonerror="true"/>
<copy file="@TEMP_HOME/qas/QAWORLD.INI" tofile="@TOMCAT_HOME/shared/lib/QAWORLD.INI" failonerror="true"/>
<replace file="@TOMCAT_HOME\shared\lib\QAWSERVE.INI" propertyFile="${extract_to}\install.properties">
<replacefilter token="@QAS_DATA_DIR@" property="qas.data.home"/>
</replace>
</target>
<target name="InstallService">
<exec executable="@TOMCAT_HOME\bin\Tomcat-NT-service-install.bat">
</exec>
</target>
<target name="UninstallService">
<exec executable="@TOMCAT_HOME\bin\Tomcat-NT-service-uninstall.bat">
</exec>
</target>
</project>
Lastly, the Lauch4j script
The Lunch4jt script that is executed: launch4jConfig.xml
<launch4jConfig>
<!-- Header types: 0-GUI, 1-console -->
<headerType>0</headerType>
<outfile>[PKG_DEV]/[FILE-NAME].exe</outfile>
<jar>[PACK_SOURCE]/[FILE-NAME].jar</jar>
<dontWrapJar>false</dontWrapJar>
<errTitle>[APP-NAME]: Installation Error</errTitle>
<customProcName>LalPacAddresshub</customProcName>
<downloadUrl>https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jre-1.5.0_15-oth-JPR@CDS-CDS_Developer</downloadUrl>
<cmdLine/>
<chdir/>
<icon>lalpac.ico</icon>
<stayAlive/>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.5.0_15</maxVersion>
<initialHeapSize>0</initialHeapSize>
<maxHeapSize>0</maxHeapSize>
</jre>
</launch4jConfig>
