Upgrading Maven on Mac OS X is generally nothing very special, but I’d like to summarize the steps I’ve done. Maybe it is helpful for users which are not so familiar with the Terminal application.

- First of all: start the Terminal application, located in the folder
/Applications/Utilities/Terminal.app. - Here you can find out which Maven version is currently running, by typing
mvn -version. You will get some output starting with the Maven version number, such as:Apache Maven 2.0.9. The latest version of Maven is 2.2.1 by the time of writing this article, so you see there is the need to upgrade. - Now you have to locate the
mvncommand in your file system. Typewhereis mvn. The output will be the complete path of the executable:/usr/bin/mvn. - This is most likely not the place where Maven is installed, but a symbolic link to the Maven executable of your system. To find out where this link refers to, type
(replace the path with your ownln -sls -l /usr/bin/mvnmvnlocation). The output will look like this:lrwxr-xr-x 1 root wheel 37 2 Sep 22:39 /usr/bin/mvn -> /usr/local/apache-maven-2.0.9/bin/mvn - Now change to the parent directory of the Maven installation.
cd /usr/local - Open Safari and download Maven from the Maven Homepage. Instead of downloading with Safari, you can also use a command line tool. Please use the mirror which is best for you:
http://apache.linux-mirror.org/maven/binaries/apache-maven-2.2.1-bin.tar.gz - Now extract the archive:
tar -xzvf apache-maven-2.2.1-bin.tar.gz - Optional: move the extracted archive to the right folder:
sudo mv apache-maven-2.2.1 /usr/local - Now link the Maven command to the new version: sudo ln -fs /usr/local/apache-maven-2.2.1/bin/mvn /usr/bin/mvn
That’s it. Now you can try if the latest version is actually installed. Type mvn -version again, and you will see:

If you are not able to execute the mvn command, it is possible that the execute flag is missing. Change this by typing chmod a+x /usr/local/apache-maven-2.2.1/bin/mvn
In 4. the right command is
ls -l /usr/bin/mvn
If you just want to know the target of a symlink
readlink /usr/bin/mvn
is also a suitably command.
Corrected point 4. Thank you.
Pingback: Sonatype Blog » In other news: Blogs and tweets
An arguably simpler way is to:
1) extract
2) set MAVEN_HOME
3) set your path to be $MAVEN_HOME\bin:$PATH;
That way it will find your new maven before the default one.
Haikal, you’re right. But assuming you haven’t set MAVEN_HOME yet, you can do the steps described in this post.
Thanks, worked like a charm!