I’ve been playing around with Windows Installer XML (WiX) recently – I used it to create the installer for Year Chart and I’ve since converted a couple of internal projects (I may publish them later) which I had originally created InstallShield installers for (with the version that came with older versions of Microsoft Visual Studio).
So, when I was involved in a discussion about installing Apache Maven 2 earlier this week I thought it sounded an interesting challenge.
I’m using Visual Studio 2010 with the Votive plugin for WiX projects and so, using this I created the base installer as an empty WiX project. Then, I copied and tweaked some of the Year Chart installer (easier than starting from scratch…).
To get the Maven 2 binaries, I downloaded the Apache Maven 2.2.1 zipped binaries and expanded them into the project. I used the
heat.exe program from the WiX installation to generate a
Fragment file which will include all the Maven binary files into the installer.
Finally, I worked out how to setup the environment variables to support running Maven 2 on the command line:
M2, and adding
Path. I’ve created them as User environment variables rather than System variables to make it easier to change them without Admin access.
Over the rest of the week, I added some Start Menu entries to uninstall the application and link to the Apache Maven web site. I also added the Apache License Version 2.0 – I had to use an RTF version because I couldn’t persuade WiX to use the text version included in the Maven distribution.
You can download the installer here:
- Apache Maven 2.2.1 Installer (updated 2012-01-08)
The installer, as with the Apache Maven code, is provided under the Apache License Version 2.0.
This version of the installer includes the following features:
- Installs Apache Maven 2.2.1 binaries (Jars)
- Presents the Apache License Version 2.0
- Configurable install location – defaults to:
C:Program FilesApache Software Foundationapache-maven-2.2.1
- Configures User Environment Variables:
- M2_HOME – the install location
- M2 – the bin directory (includes
- Path – appends %M2% to the User path so you can use it easily on the command line.
- Adds a Start Menu folder containing:
- Apache Maven Website URL
- Uninstall link
NOTE: Maven is a Java tool, so you must have a Java installed in order to proceed. More precisely, you need a Java Development Kit (JDK) version 1.5 or greater , the Java Runtime Environment (JRE) is not sufficient.
Once installed you will be able to run Maven from the command line – you can test this by opening a command window and typing:
It’s time to give it a try – if you are new to Maven you might like to Test Drive Apache Maven on Your Existing Projects.
For me, there are a few extra installer features I’d like to try out – like checking the Java version. And I will be adding more articles about Maven in the future.
Let me know if it’s any use to you – or if it you have any problems with it.