To compile izpack using Maven, use the izpack-maven-plugin. There is good documentation at the izpack-maven-plugin page, but this page will describe how to use the most recent izpack plugin (5.0.0-beta9 at the time of this writing).
I'll assume you have some custom izpack panels, but if you don't, you can omit some of the steps that we go over here:
If you have custom panels, you'll want to put them in their own Maven module. This module should be a standard Maven project, but you should include izpack as a provided dependency:
<dependencies>
<dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-compiler</artifactId>
<version>${izpack.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
We use scope = provided because we only need Maven to use the izpack dependency at compile time. In this project, you can create your custom IzPack panels. Be sure that the Java package names that contain your custom IzPack panels begin with "com", "net", or "org", or else they will not be able to be loaded by your IzPack installer.
Now, create a separate Maven module that will produce your izpack installer.
The basic strategy we'll use is this:
maven-antrun-plugin
to copy our izpack descriptor file and resources into this "staging" area. maven-dependency-plugin
to copy the jar with our custom panels, and any other jar dependencies that we want in our installer. We'll configure two different "executions" of the maven-dependency-plugin
; we'll have this plugin copy our application jars into one location, and the custom panel jars into a separate location.izpack-maven-plugin
to point it to our staging area and our installer descriptor.<properties>
<izpack.staging>${project.build.directory}/staging</izpack.staging>
</properties>
(Note that ${project.build.directory}
typically references the compilation ./target/ directory of your module.)
We'll want to add at least two dependencies–one will be the dependency that contains your custom panel, the other(s) will be the dependency that contains your actual Java application. My dependencies look like this:
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>myapplication</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>mycustompanels</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
maven-antrun-plugin
We'll use the maven-antrun-plugin
to copy our installer descriptor and installer resources (images, text files, etc.) into our "staging" area.
I put my installer descriptor and resources into src/izpack
in my module.
maven-dependency-plugin
TODO
<build>
<plugins>
<!-- copy izpack resources into izpack staging area, expected by izpack.xml -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-staging-area</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy todir="${izpack.staging}">
<fileset dir="${basedir}/src/izpack"/>
</copy>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<!-- copy product jars to izpack staging lib -->
<id>copy-product-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${izpack.staging}/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeScope>system</excludeScope> <!-- tools.jar -->
<excludeGroupIds>org.codehaus.izpack</excludeGroupIds>
</configuration>
</execution>
<execution>
<!-- copy izpack custom (custom panels, etc.) jars to izpack staging custom -->
<id>copy-izpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${izpack.staging}/custom</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeArtifactIds>heatlamp-assembly-izpack-base</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>izpack</goal></goals>
<configuration>
<!-- base for relative paths in izpack descriptor -->
<baseDir>${izpack.staging}</baseDir>
<installFile>${basedir}/src/izpack/install.xml</installFile>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-panel</artifactId>
<version>${izpack.version}</version>
</dependency>
<dependency>
<groupId>presspass.heatlamp</groupId>
<artifactId>heatlamp-assembly-izpack-base</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
[1] http://izpack.codehaus.org/izpack-maven-plugin/
[2] https://github.com/aspear/izpack5-example-installer