Easy Installer with IzPack

Normally, when an application is completed, it is customary to give a war or zip to the deployment manager with the accompanying instructions.


But would it not be much easier for the administrator to have an interactive installer who assists him with the installation process. With IzPack it is possible to create a platform independent installer. How to do this is, including the integration in a maven build is described in this post.

Create the IzPack install script


IzPack compiles the installer using a XML descriptor with the default name of install.xml.
The following example is a simple listing of such a xml file. (For a detailed explanation see the IzPack documentation: http://izpack.org/documentation/index.html)
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
<info>
<appname>@{project.name}</appname>
<appversion>@{project.version}</appversion>
<authors>
<author name="Willem Dekker" email="willem@42.nl" />
</authors>
<url>http://www.42.nl</url>
<javaversion>1.6</javaversion>
<requiresjdk>no</requiresjdk>
</info>

<guiprefs width="640" height="480" resizable="yes" />

<locale>
<langpack iso3="eng" />
</locale>

<panels>
<panel classname="HelloPanel" />
<panel classname="TargetPanel"/>
<panel classname="InstallPanel"/>
<panel classname="FinishPanel" />
</panels>

<packs>
<pack name="Core" required="yes">
<description>Core installation files</description>
<file src="../@{project.build.finalName}.jar" targetdir="$INSTALL_PATH" unpack="true" />
</pack>
</packs>

</installation>

Please note that the @{...} notations are actual maven pom properties.

The installer will include four steps, as shown in the panels element (line 20), these panels are available by default in IzPack, but of course there is the possibility to add custom panels.

As shown on line 30 (packs element) the installer will copy the included jar to the installation directory and extract and unpack it during the installation process.

Include IzPack into the maven build


To build the installer from within a maven built the IzPack Maven Plugin should be used.
A typical configuration is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

...

<build>
<plugins>
<plugin>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-maven-plugin</artifactId>
<version>1.0-alpha-5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>izpack</goal>
</goals>
<configuration>
<installerFile>${project.build.directory}/${project.build.finalName}-installer.jar</installerFile>
</configuration>
</execution>
</executions>

<dependencies>
<dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-standalone-compiler</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

...

</project>

The plugin is executed during the package phase and will create an executable installer using the install.xml file. The default location of this file: ${basedir}/src/izpack/install.xml.

If you then run mvn clean package, the compiled installer can be found in the target folder with the name: ${project.build.finalName}-installer.jar. When you run it by double-clicking or a java -jar command, the installer will launch and guide you through the installation.

IzPack Welcome Screen

Conclusion


Of course, this is only the tip of the iceberg regarding IzPack.
But it shows how easy it is to create an interactive installer for your software.
IzPack is really a flexible piece of software and allows you to create an elaborate installer with lots of options.
With IzPack you will have run out of excuses for not delivering an easy-to-install deliverable. Try it, you might even make friends with the operations department.

No comments:

Post a Comment