Launch4J Plugin

Overview

Integrates the generation of a Launch4J executable wrapper into the maven build process. The plugin bundles Launch4J version 3.0.0-pre1. For more information regarding the usage of Launch4J please refer to the Launch4J documentation. We use this plugin in conjunction with IzPack to create a windows executable installer. Hopefully it will be useful within other projects as well, i.e. non-alakai related projects.

Note that this plugin was originally developed by Paul Jungwirth and released under the GPL version 2.0, but was never deployed to a public repository. It was instead deployed to the 'Akathist Repository' which was hosted at http://www.9stmaryrd.com/maven. Unfortunately, for reasons unknown to us, the site and repository are no longer available, which is why we've deployed the plugin under Bluestem Software's group id. Isn't open source a wonderful thing?

Examples

Enable The Plugin

The plugin is enabled via a build execution tag associated with the build's 'verify' phase. An example configuration is included below (which is the config we use to generate the alakai executable wrapper.) Note, for repeatable builds, you should 'peg' the plugin to a specific version as shown in the example below.

...
<build>
  <plugins>
    <plugin>
      <groupId>org.bluestemsoftware.open.maven.plugin</groupId>
      <artifactId>launch4j-plugin</artifactId>
      <version>1.0.0.0</version>
      <executions>
        <execution>
          <id>launch4j</id>
          <phase>verify</phase>
          <goals>
            <goal>launch4j</goal>
          </goals>
          <configuration>
            <dontWrapJar>false</dontWrapJar>
            <headerType>gui</headerType>
            <outfile>target/alakai-standalone-assembly-${project.version}-install.exe</outfile>
            <jar>target/alakai-standalone-assembly-${project.version}-install.jar</jar>
            <errTitle>alakai</errTitle>
            <jre>
              <minVersion>1.6.0</minVersion>
            </jre>
            <splash>
              <file>${basedir}/src/main/installer/images/splash.bmp</file>
              <waitForWindow>true</waitForWindow>
              <timeout>60</timeout>
              <timeoutErr>false</timeoutErr>
            </splash>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
...

Additional Example

Here's another example which defines some additional configuration elements (no schema was defined within the original plugin project so you're kind of on your own here until one is developed. sorry.)

...
<build>
  <plugins>
    <plugin>
      <groupId>org.bluestemsoftware.open.maven.plugin</groupId>
      <artifactId>launch4j-plugin</artifactId>
      <version>1.0.0.0</version>
      <executions>
        <execution>
          <id>launch4j</id>
          <phase>verify</phase>
          <goals>
            <goal>launch4j</goal>
          </goals>
          <configuration>
            <headerType>console</headerType>
            <outfile>target/alakai-standalone-assembly-${project.version}-install.exe</outfile>
            <jar>target/alakai-standalone-assembly-${project.version}-install.jar</jar>
            <errTitle>alakai</errTitle>
            <classPath>
              <mainClass>com.my.company</mainClass>
              <addDependencies>false</addDependencies>
              <preCp>anything</preCp>
            </classPath>
            <jre>
              <minVersion>1.5.0</minVersion>
            </jre>
            <versionInfo>
              <fileVersion>1.2.3.4</fileVersion>
              <txtFileVersion>txt file version</txtFileVersion>
              <fileDescription>a description</fileDescription>
              <copyright>my copyright</copyright>
              <productVersion>4.3.2.1</productVersion>
              <txtProductVersion>txt product version</txtProductVersion>
              <productName>product name</productName>
              <internalName>internal name</internalName>
              <originalFilename>original.exe</originalFilename>
            </versionInfo>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
...

One Last Example

Here's an example provided by Paul Jungwirth within the documentation that accompanied his plugin and which defines two separate executions, one which generates an executable which runs in console mode and one which runs in GUI mode:

...
<build>
  <plugins>
    <plugin>
      <groupId>com.akathist.maven.plugins.launch4j</groupId>
      <artifactId>launch4j-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>l4j-clui</id>
          <phase>package</phase>
          <goals><goal>launch4j</goal></goals>
          <configuration>
            <headerType>console</headerType>
            <outfile>target/encc.exe</outfile>
            <jar>target/encc-1.0.jar</jar>
            <errTitle>encc</errTitle>
            <classPath>
              <mainClass>com.akathist.encc.Clui</mainClass>
              <addDependencies>false</addDependencies>
              <preCp>anything</preCp>
            </classPath>
            <jre>
              <minVersion>1.5.0</minVersion>
            </jre>
            <versionInfo>
              <fileVersion>1.2.3.4</fileVersion>
              <txtFileVersion>txt file version?</txtFileVersion>
              <fileDescription>a description</fileDescription>
              <copyright>my copyright</copyright>
              <productVersion>4.3.2.1</productVersion>
              <txtProductVersion>txt product version</txtProductVersion>
              <productName>E-N-C-C</productName>
              <internalName>ccne</internalName>
              <originalFilename>original.exe</originalFilename>
            </versionInfo>
          </configuration>
        </execution>
        <execution>
          <id>l4j-gui</id>
          <phase>package</phase>
          <goals><goal>launch4j</goal></goals>
          <configuration>
            <headerType>gui</headerType>
            <outfile>target/enccg.exe</outfile>
            <jar>target/encc-1.0.jar</jar>
            <errTitle>enccg</errTitle>
            <classPath>
              <mainClass>com.akathist.encc.Gui</mainClass>
            </classPath>
            <jre>
              <minVersion>1.5.0</minVersion>
            </jre>
            <versionInfo>
              <fileVersion>1.2.3.4</fileVersion>
              <txtFileVersion>txt file version?</txtFileVersion>
              <fileDescription>a description</fileDescription>
              <copyright>my copyright</copyright>
              <productVersion>4.3.2.1</productVersion>
              <txtProductVersion>txt product version</txtProductVersion>
              <productName>E-N-C-C</productName>
              <internalName>ccne</internalName>
              <originalFilename>original.exe</originalFilename>
            </versionInfo>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <executions>
        <execution>
          <id>assembly</id>
          <phase>package</phase>
          <goals><goal>attached</goal></goals>
          <configuration>
            <descriptors>
              <descriptor>assembly.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
...