Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Syntax highlighting and update to 5.0.0-rc1

...

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 rc1 at the time of this writing).

...

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:

...

Code Block
xml
xml
<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.

...

We'll be referencing the staging area location a few times in the pom, so let's configure it as a pom property to make things clearer. Let's also configure the izpack version we're using, which we'll want to reference in a few places in the pom, as well. Put this under the root element of your pom file:
Code Block
xml
xml
<properties>

...


   <izpack.version>5.0.0-

...

rc1</izpack.version>

...


   <izpack.staging>${project.build.directory}/staging</izpack.staging>

...


</properties>

Notes:

  • ${project.build.directory} typically references the compilation ./target/ directory of your module
  • Properties from your Maven project compiling the IzPack project can be directly references in the install.xml using the property name enclosed in '@{' and '}' , for example:
    <jar src="@{izpack.staging}/lib/appcore.jar"/>
    This applies just on properties defined in the calling project, not for properties seen in the calling project.

...

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:

...

Code Block
xml
xml
<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>
Configure the maven-antrun-plugin

...

Put your installer descriptor and resources underneath src/izpack in your module. In your pom's <build> section, configure maven-antrun-plugin to copy this entire directory to our staging area:

Code Block
xml
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>
Configure the maven-dependency-plugin

We'll configure the maven-depenency-plugin to copy both our application jars and the jar with our custom panel. Here's how it looks (see the inline XML comments for more details):

Code Block
xml
xml
   <plugin>

...


       <artifactId>maven-dependency-plugin</artifactId>

...


          <executions>

...


             <execution>

...


                <!-- copy *application* 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> <!-- this excludes tools.jar, e.g. --> 

...


                      <excludeArtifactIds>mycustompanels</excludeArtifactIds> <!-- IMPORTANT: don't copy custom panels where our application jars live -->

...


                      <excludeGroupIds>org.codehaus.izpack</excludeGroupIds> <!-- IMPORTANT: we don't want to copy the izpack dependency where our application jars live -->

...


                   </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>mycustompanels</includeArtifactIds> <!-- IMPORTANT: this causes *only* our custom panels to be copied -->

...


               </configuration>

...


            </execution>

...


       </executions>

...


 </plugin>

Some key points:

  • The first execution section configures copying our application jars to the lib/ directory under our staging directory (i.e., target/staging/lib). Note that we have to explicitly exclude the izpack dependency as well as our custom panels dependency. We don't need these showing up in our installed application!
  • The second execution section configures copying our custom panels jar to the custom/ 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 to custom/. It wouldn't hurt anything if this happened, but why do unnecessary work?

...

Configure the izpack-maven-plugin

We need to tell the izpack-maven-plugin what to use as the base directory (this is our staging area), and also tell it the install file to use:

<plugin>
Code Block
xml
xml
<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-SNAPSHOT</version>


      </dependency>


    </dependencies>


 </plugin>
Some key points:
  • Even though you've already declared your custom panels dependency as a project dependency, you'll also need to declare it as a dependency to the izpack plugin itself, or else you will see classloading errors. (This is because Maven gives every plugin execution its own classloader, which cannot see the classpath of the project itself.)

Create Your Installer Descriptor

Your installer descriptor should reference resources and jars relative to the staging area. For example, here is a resources section in our installer descriptor (i.e., install.xml):

Code Block
xml
xml
<resources>


    <res src="@{izpack.staging}/common_resources/img/install-sidebar.png" id="Installer.image"/>


    <res src="hello.html" id="HTMLHelloPanel.info"/>


    <res src="license.html" id="HTMLLicencePanel.licence"/>


</resources>
Note that these resources are originally under src/izpack. They are copied from this directory to the staging area, where the izpack compiler will look for them.

Also, don't forget to tell the izpack compiler about your custom panels jar. In your install.xml file:

<jar src="custom/mycustompanels.jar"/>
Info
titleNote

You should see now why we use the <stripVersion>true</stripVersion> option of the maven-dependency-plugin, so that it copies the custom jar dependency without the version in its name. This way, we can reference our custom panels jar from our installer descriptor without having to know its version of it.

Here's an example of referencing a custom panel. Again, in our installer descriptor:

<panels>
Code Block
xml
xml
<panels>
  <panel classname="com.mycompany.izpack.panel.MyHelloPanel"/>

</panels>

Note that we use the fully qualified name of the panel class.

...

When finished, the entire build section of our pom should look something like this:

...

Code Block

...

xml
xml
<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> <!-- 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>

...


                  <excludeTransitive>false</excludeTransitive>

...


                  <stripVersion>true</stripVersion>

...


                  <overWriteReleases>true</overWriteReleases>

...


                  <overWriteSnapshots>true</overWriteSnapshots>

...


                  <overWriteIfNewer>true</overWriteIfNewer>

...


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

TODO

References

[1] http://izpack.codehaus.org/izpack-maven-plugin/

...