Customizing the NetBeans Installer – Using Maven

This blog post will demonstrate how to customise the NetBeans Installer which can be used when creating NetBeans platform based applications. First of all you will need to create a new Maven based NetBeans application project. You can get full instructions on how to create a project here. Just give your project a simple name or even complete the full tutorial and then follow this guide.

In the Maven Module with the name app on the end open the pom.xml. This Module is responsible for building the final application. At the end of the pom.xml file you will see a section that looks like the following:

<profiles>
    <profile>
    <id>deployment</id>
    <build>
        <plugins>
            <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>nbm-maven-plugin</artifactId>
            <executions>
                <execution>
                <id>extra</id>
                <goals>
                    <goal>autoupdate</goal>
                    <goal>webstart-app</goal>
                    <goal>build-installers</goal>
                </goals>
                </execution>
            </executions>
            </plugin>
        </plugins>
    </build>
    </profile>
</profiles>

 

Remove the goals for autoupdate and webstart as we do not need these for this demo. The build-installers does precisely that builds the installers. So if your ran maven on the top level parent module with the profile name deployment, the application plus any installers will be built.

 

In the above snipet add the following configuration values to the nbm-maven-plugin to produce only a Windows Installer.

<configuration>
    <installerOsLinux>false</installerOsLinux>
    <installerOsSolaris>false</installerOsSolaris>
    <installerOsMacosx>false</installerOsMacosx>
</configuration>

To provide a custom .conf file with the application use the value etcConfFile as shown below. The location of the file is under src/main/resources for the app project.

<etcConfFile>${project.build.directory}/conf/${brandingToken}.conf</etcConfFile>

To use a custom License file you can do something like the following.

<installerLicenseFile>${basedir}/src/main/resources/License.txt</installerLicenseFile>

If you wish to configure more like provide your own text values for the installer and locations for files to be installed you will need to create a template.xml file. The template.xml file defines the values used by the installer. You can change quite a lot here as you can see from the following snippet.

<userSettings>
    <nbi.icon.file>${basedir}/src/main/resources/padlock48.png</nbi.icon.file>
    <wizard.left.image>${basedir}/src/main/resources/wizard-description-background-left.png</wizard.left.image>
    <suite.props.app.installdir>${project.name}-${project.version}</suite.props.app.installdir>
    <suite.props.app.installdir.windows>Company Name\\${project.name}-${project.version}</suite.props.app.installdir.windows>
</userSettings>

The settings all change the way the installer acts and the images the installer uses, suite.props.app.installdir.windows provides the location of which the product will be installed.

All source code can be found here at bitbucket. People are free to contribute examples or to create more examples if they wish.