1. John Oxley
  2. wix-maven-plugin

Overview

HTTPS SSH

What is it?

This package started off as a fork of the excellent NPanday WiX plugin. I did so because the npanday plugin depended (unnecessarily)on packages that are no longer available. Since then this wix-maven-plugin has been extended to deal with correctly escaping paths.

Prerequisites

  • The WiX Toolset must be installed.
  • Make sure that the WiX bin directory is on your path. Normally C:\Program Files (x86)\WiX Toolset v3.8\bin.

Use

<plugin>
    <groupId>org.bitbucket.joxley</groupId>
    <artifactId>wix-maven-plugin</artifactId>
    <version>1.1.1</version>
    <configuration>
        <workingDirectory>${basedir}/wixroot</workingDirectory>
        <extensions>
            <extension>WixUtilExtension</extension>
            <extension>WixUIExtension</extension>
            <extension>installer\WixSystemToolsExtension.dll</extension>
        </extensions>
        <sourceFiles>
            <sourceFile>target/filtered-installer/Installer.wxs</sourceFile>
        </sourceFiles>
        <outputDirectory>target</outputDirectory>
        <objectFiles>
            <objectFile>target/MyApp.wixobj</objectFile>
        </objectFiles>
        <outputFile>target/MyApp-${project.version}_${profile.name}.msi</outputFile>
    </configuration>
    <executions>
        <execution>
            <id>wix</id>
            <goals>
                <goal>candle</goal>
                <goal>light</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Tip

To get the version from your maven pom.xml into the file, I put the Installer.wxs file into an installer directory and configured that directory for resource filtering.

<resources>
    <resource>
        <directory>src/main/java</directory>
    </resource>
    <resource>
        <directory>installer</directory>
        <filtering>true</filtering>
        <targetPath>../filtered-installer</targetPath>
    </resource>
</resources>
<sourceDirectory>src/main/java</sourceDirectory>

You can then use maven substitutions in the Installer.wxs file. e.g. In the Product tag, set Version="{majorVersion}.${minorVersion}.${incrementalVersion}".

WiX doesn't like a version number that ends in -SNAPSHOT which is why ${project.version} is not recommended.