How to do upgrade maven in Mac OS X?

How to do upgrade maven in Mac OS XMaven Build tool comes out-of-the-box (OOTB) with Mac OS X operating system. However developer reach the point to upgrade maven in Mac OS X. Article describes upgrade steps that is easy to use.

Default location of maven installation on Mac OS X is /usr/share/maven; well its actually symbolic link.  Following is the typical physical location of installed maven is under java directory /usr/share/java/maven-x.x.x

Note: Article applies to 

  • OS X version 10.6 & above
  • Higher Maven versions (hopefully in future too)
  • Maven version denoted as x.x.x in the article
  • Feel free to leave a comment for any queries


Warm Up!

Let’s take a look at existing maven version

mac-book-pro:~ jeeva$ mvn --version
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_24

Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.7" arch: "x86_64" Family: "mac"

mac-book-pro:~ jeeva$

Just few more steps ahead to upgrade the required or latest version of maven in your machine.


Steps to do

Step 1

Download maven apache-maven-x.x.x-bin.tar.gz from Apache Maven website http://maven.apache.org/download.html.

Step 2

We are going to extract the downloaded maven tar into following physical directory /usr/share/java/maven-x.x.x as mentioned above

mac-book-pro:~ jeeva$ sudo tar -xvf apache-maven-x.x.x-bin.tar.gz -C /usr/share/java/

Step 3

Removing existing symbolic link using unlink the existing maven reference from /usr/share/

mac-book-pro:~ jeeva$ ls -ltr
lrwxr-xr-x    1 root   wheel    16B Mar 22 01:41 maven@ -> java/maven-x.x.x
mac-book-pro:share jeeva$ sudo unlink maven

Step 4

We now reached the final part; creating a symbolic link on /usr/share to get your upgraded maven :)

mac-book-pro:share jeeva$ sudo ln -s /usr/share/java/apache-maven-x.x.x /usr/share/maven

Maven Upgrade is Complete

Now, just take a look of upgraded maven version

mac-book-pro:~ jeeva$ mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: /usr/share/maven
Java version: 1.6.0_24

Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.7" arch: "x86_64" Family: "mac"

mac-book-pro:~ jeeva$

Wow, you did it! Successfully upgraded maven in your Mac OS X.