Updating Maven on Mac OS X

>After some issues on the mailing lists with Maven versions for building Sakai, it became apparent that upgrading Maven on OS X was difficult, which is why there was a requirement to support Maven 2.0.6 and implement workarounds for it’s bugs which have been fixed in more recent versions.

I have been building Sakai 2.5 and upwards with Maven 2.0.9 since September 2008 without a hitch. I can’t remember the reason I upgraded but I think it was another bug I came across!
I have produced some notes below which will walk you through upgrading Maven on OS X.
1. Download Maven
2. Unpack the archive on your Desktop by double clicking it.
It will extract to a folder called maven-2.x.x (ie maven-2.0.9)
3. Open Terminal and issue the following commands:
sudo mv ~/Desktop/maven-2.0.9 /usr/local/
NOTE: If you cannot use sudo because of local restrictions you can install it locally, perhaps in your home directory somewhere. Just substitute the path you use in the following steps.
4. OPTIONAL. Update any symlink you might have to the new Maven directory:
cd /usr/local
sudo rm m2 (where m2 was my symlink m2 -> maven-2.0.6)
ln -s maven-2.0.9 m2
You now have a symlink m2 -> maven-2.0.9
5. ONLY REQUIRED IF YOU DO NOT USE SYMLINKS, ie step 4. Update your M2_HOME environment variable:
export M2_HOME=/usr/local/maven-2.0.9
If you use symlinks like /usr/local/m2 then your M2_HOME can point to /usr/local/m2 and you don’t need to change anything except the symlink in step 4.
6. Check your PATH
In order to use the correct version of Maven, check your path contains $M2_HOME/bin. Mine looks like:
PATH=$PATH:$MYSQL_HOME/bin:$M2_HOME/bin:/usr/local/bin:$HOME/bin
export PATH
and this is in .profile in my home directory.
7. Test:
mvn -v

Maven version: 2.0.9
Java version: 1.5.0_16
OS name: “mac os x” version: “10.5.6” arch: “i386” Family: “unix”
Done. Simple eh 🙂
Advertisements

4 thoughts on “Updating Maven on Mac OS X

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s