...
Create a separate Maven project that will produce your izPack installer. You can refer to the IzPack Maven Plugin Reference section for details on the plug-in and the meaning of the configuration settings.
The basic strategy is as follows:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<properties> <izpack.version>5.0.0<9</izpack.version> <izpack.staging>${project.build.directory}/staging</izpack.staging> </properties> |
...
- Add the dependency that contains your actual Java application to be installed.
- If custom panels are used, add the dependency that contains your custom panel,
Code Block | ||||
---|---|---|---|---|
| ||||
<dependencies> <dependency> <groupId>com.mycompany</groupId> <artifactId>myapplication</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.mycompany</groupId> <artifactId>myapplication-utilities</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.mycompany</groupId> <artifactId>mycustompanels</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> |
...
- Add the base directory to the
izpack-maven-plugin.
This is our staging area. - Add the location of the install file.
Code Block | ||||
---|---|---|---|---|
| ||||
<plugin> <groupId>org.codehaus.izpack</groupId> <artifactId>izpack-maven-plugin</artifactId> <version>${izpack.version}</version> <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> </dependencies> </ . . . </dependencies> </plugin> |
Create Your Installer Descriptor
...
When finished, the entire build section of our pom should look something like this:
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0"?>. . . <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> <configuration> <excludeTransitive>false</excludeTransitive> <stripVersion>true</stripVersion> <overWriteReleases>true</overWriteReleases> <overWriteSnapshots>true</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <excludeScope>system</excludeScope> </configuration> <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> <excludeScope>system</excludeScope> <!-- this excludes tools.jar, e.g. --> <excludeArtifactIds>mycustompanels</excludeArtifactIds> <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> <includeArtifactIds>mycustompanels</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>com.mycompany</groupId> <artifactId>mycustompanels</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </plugin> </plugins> </build> . . . |
As mentioned at the start of this article, the dependencies of your application are project dependencies and need to be specified as normal Maven dependencies in the project's dependencies section.
Code Block | ||||
---|---|---|---|---|
| ||||
. . . </build> <dependencies> <dependency> <groupId>com.mycompany</groupId> <artifactId>myapplication</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <version>1<groupId>com.0<mycompany</version>groupId> <<artifactId>mycustompanels</dependency>artifactId> </dependencies><version>1.0-SNAPSHOT</version> </plugin>dependency> </plugins>dependencies> </build>project> |
Using Custom Panels
If you have custom panels, they should be developed in a separate Maven project. This is a standard Maven project, but you should include izPack as a provided dependency:
...
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.
maven-dependency-plugin
to copy the custom panel jar to the staging area.This example include a section for custom panels which may be omitted if it does not apply.
Code Block | ||||
---|---|---|---|---|
| ||||
<plugin> <groupId>org.codehaus.izpack</groupId> <artifactId>izpack-maven-plugin</artifactId> <version>${izpack.version}</version> <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>com.mycompany</groupId> <artifactId>mycustompanels</artifactId> <version>1.0<0-SNAPSHOT</version> </dependency> </dependencies> </plugin> |
Some key points:
- Even though the custom panels dependency is declared as a project dependency, it also must be declared as a dependency to the IzPack plugin itself, or else you will see classloading errors. Maven gives every plugin execution its own classloader, which cannot see the classpath of the project itself.
Add the <execution> section
- Add the second
execution
section to copying of the custom panels jar to thecustom/
directory under our staging directory (i.e.,target/staging/custom
). Note that we explicitly include our custom panels dependency so that no other jars are copied tocustom/
. It wouldn't hurt anything if this happened, but why do unnecessary work.
Summary
When finished, the entire build section of the pom should look something like this:
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0"?> . . . <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> <configuration> <excludeTransitive>false</excludeTransitive> <stripVersion>true</stripVersion> <overWriteReleases>true</overWriteReleases> <overWriteSnapshots>true</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <excludeScope>system</excludeScope> </configuration> <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> <excludeScope>system</excludeScope> <!-- this excludes tools.jar, e.g. --> <excludeArtifactIds>mycustompanels</excludeArtifactIds> <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> <includeArtifactIds>mycustompanels</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>com.mycompany</groupId> <artifactId>mycustompanels</artifactId> <version>1.0</version> </dependency> </dependencies> </plugin> </plugins> </build> |
Add the custom panel jar to the installer description
...
Note that we use the fully qualified name of the panel class.
Troubleshooting
There are a few simple things to check if your installer is not created properly.
...