Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Apache Ant integration

IzPack can be easily integrated inside an Ant build process.

E.g.:

...

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

  • a Java runtime environment (Oracle JRE, OpenJDK etc.), version 6 or above,
    Apache Ant will probably require the $JAVA_HOME environment variable to be set to it.
  • a preinstalled version of the Apache Ant runtime (version 1.6.5 or above),
  • the latest distribution installer of IzPack 5.


The IzPack task takes the following parameters as attributes:
  • input: the XML installation file. The installation can be specified as an external file, or embedded using a config child element.
  • output: the output jar installer file
  • installerType: (optional), possible values: standard or web. If web, the <webdir> attribute must be specified in the input file. Used to force creation of a standard installer when the <webdir> attribute has been used.
  • inheritAll: (optional, boolean). If true all properties defined in the ant build process are transmitted to izpack parser for substitution. 

  • baseDir: the base directory to resolve the relative paths
  • izPackDir: the IzPack home directory (the target directory when executing the izpack-dist.jar)
  • mkdirs: whether to automatically create the parent directories of the installer jar to be built.
  • inheritAll: If true, pass all Ant properties to IzPack. Defaults to false.
  • compression:
    Optional compression format for single files defined in <packs>. All files in all packs except those explicitly marked as <pack200/> are automatically added compressed in the given format and uncompressed later when the installer starts. This may significantly decrease the installer size, but take some more time to compile the installer and install the files later.
    See also Compressing pack files for more information on this feature.
    Possible values: default |gz |bzip2 |xz |lzma |deflate
    Default: default (uncompressed)
    Since: IzPack 5.1 (has been broken in 5.0) 
  • compressionLevel: The compression level of the resulting installer jar file.
    This attribute has nothing in common with the compression attribute declared above, which defines compression for single files added in packs, but defines just the compression level of the whole installer jar file itself.
    Possible values: -1 (choose default compression level), 0 (fastest compression) .. 9 (best compression)
    Default: 9 

Nested elements:

  • <config>
    Used for embedding the contents of install.xml as CDATA directly to the build file (see the example in the section below)
  • <property>
    Add a property to the build visible only to the IzPack task. The Syntax is the same like for defining properties in Ant.
  • <propertyset>
    Add a property set to the build visible only to the IzPack task. The Syntax is the same like for defining a propertyset in Ant. 

Here is how the Ant build file may look like:

...


Code Block
languagehtml/xml
titleExample
<?xml version="1.0" encoding="UTF-8"?>

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

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

The IzPack task takes the following parameters:
  • 'input': the XML installation file. The installation can be specified as an external file, or embedded using a config child element.
  • 'output': the output jar installer file
  • 'installerType': optional. standard or web. If web, the <webdir> attribute must be specified in the input file. Used to force creation of a standard installer when the <webdir> attribute has been used.
  • 'baseDir': the base directory to resolve the relative paths
  • 'IzPackDir': the IzPack home directory

You can find a fully compilable example here:

View file
nametest.zip
height250

Using the above example:

  • Download the latest distribution installer and install it locally ($HOME/IzPack is assumed to be the installation directory).
  • Unpack test.zip in a working directory of your choice.
  • Call the Ant build (tested with Ant 1.9.6):
    cd test
    ant

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

Anchor
Embedding contents as CDATA
Embedding contents as CDATA
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. For example:

...

Code Block
languagexml
titleExample
<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>

...


   <info>
      <appname>JBossAS</appname>
      <appversion>4.0.2</appversion>
      <appsubpath>jboss-4.0.

...

2</appsubpath>

...

      <authors>

...


      <authors>
         <author name="JBoss Inc." email="sales@jboss.com"/>

...


      </authors>

...


      <url>@{jboss.home.url}</url>

...

      <javaversion>1.4</javaversion>

...


      <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.