Apache Ant integration

IzPack can be easily integrated inside an Ant build process.

You need to have the following prerequisites installed on your local system:


The IzPack task takes the following parameters as attributes:

Nested elements:

Here is how the Ant build file may look like:


<?xml version="1.0" encoding="UTF-8"?>

<project name="izpack" default="compile">
  
  <property name="izpack-dist" value="${user.home}/IzPack"/>
  <property name="izpack-installer" value="setup.jar"/>
  
  <path id="lib.path">
    <fileset dir="${izpack-dist}/lib" includes="*.jar"/>
  </path>
  
  <taskdef name="izpack"
           classname="com.izforge.izpack.ant.IzPackTask"
           classpathref="lib.path"
           />
  
  <target name="compile">
    <echo message="Makes the installer using IzPack to ${izpack-installer}"/>
    <izpack input="${basedir}/src/main/resources/install.xml"
            output="${basedir}/${izpack-installer}"  
            installerType="standard"              
            basedir="${basedir}/src/main/resources"
            izPackDir="${izpack-dist}"/>
    <echo message="${izpack-installer} created"/>
  </target>
  
</project>

The above assumes that the IzPack distribution has been installed to ${user.home}/IzPack.

You can find a fully compilable example here:

Using the above example:

It builds an executable installer setup.jar in the working directory.

Embedding the installation file contents as CDATA

Instead of using the 'input' attribute to specify an external installation document, you can embed the installation config as a child of the IzPack task using a config child element with a CDATA section.

<property name="jboss.home.url" value="http://www.jboss.com/" />
...
 
<!-- Call IzPack with an embedded install using the config element -->
<izpack output="${dist.dir}/IzPack-install.jar"
        installerType="standard"
        basedir="${dist.dir}"
        inheritAll="true"
        izPackDir="${dist.dir}/">
        <config><![CDATA[
<installation version="1.0">
   <info>
      <appname>JBossAS</appname>
      <appversion>4.0.2</appversion>
      <appsubpath>jboss-4.0.2</appsubpath>
      <authors>
         <author name="JBoss Inc." email="sales@jboss.com"/>
      </authors>
      <url>@{jboss.home.url}</url>
      <javaversion>1.4</javaversion>
   </info>
...
        ]]></config>
</izpack>


Property references of the form


@{x}


are replaced by the associated x ant property if it is defined.