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.
Note: I’ve now added a Download Page with installers for version 2 & 3 and added the sources to GitHub.
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.
8 comments on “Windows Installer for Apache Maven 2”
Thx Simon 🙂
Good one Simon …
Getting Error on this command ….
Would be please me to rectify the mistake
C:workspace-newmaven-test>mvn archetype:generate -DgroupId=com.mkyong.core -DartifactId=mkyong-core -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects…
[INFO] Searching repository for plugin with prefix: ‘archetype’.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: ‘org.apache.maven.plugins’ could not be retrieved from repository: central due to an error: Error transferring file: Connection reset
[INFO] Repository ‘central’ will be blacklisted
[ERROR] BUILD ERROR
[INFO] The plugin ‘org.apache.maven.plugins:maven-archetype-plugin’ does not exist or no valid version could be found
[INFO] For more information, run Maven with the -e switch
[INFO] Total time: 42 seconds
[INFO] Finished at: Fri Mar 16 17:53:17 IST 2012
[INFO] Final Memory: 1M/2M
‘cmd’ is not recognized as an internal or external command,
operable program or batch file.
That doesn’t look like a problem with the installer – Maven was unable to retrieve the archetype plugin from “central” repository. It needs to have access to the internet to do this. Is your computer connected to the internet – and if there is an internet Proxy you will need to set that up. Some organisations also setup an internal Nexus or similar repository servers.
Have a look at http://maven.apache.org/guides/introduction/introduction-to-repositories.html or http://maven.apache.org/settings.html.
Also, if you’re using it on a corporate network have a look at
Thanks for your help .Installed succesfully.
Would like to know how to execute App.java .
While executing gives error as :::
Exception in thread “main” java.lang.NoClassDefFoundError: App (wrong name: com/
at java.lang.ClassLoader.defineClass1(Native Method)
Without seeing the contents of App.java it’s hard to say. Check that it is in the right directory (./src/main/java/com/mkyong/core) with a package com.mykong.core and a class inside called App.
Your setup missed the “” after %M2_HOME% in the M2 env. variable. running the command mvn or anything in the bin directory will not work
Hello, Quang Pham. I have checked installations with this installer on Windows 7 and XP and also verified the details in the WiX file. The trailing slash is definitely there and the “mvn” command works properly on all environments I have tried.
Is it possible that you have an existing entry in your User or System environment variables that is affecting this? Do you have a particular system version that is affecting it?