Posted on July 16, 2012 , Last modified : December 13, 2012
By mkyong
Since Lion 10.7.1 (correct me if wrong), Mac OS X comes with Apache Maven 3 built in, and can be located at/usr/share/maven.
1. Maven Verification
In terminal, issue the command mvn -version.
$mvn -version
Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /usr/share/maven
Java version: 1.6.0_33, vendor: Apple Inc.
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.7.4", arch: "x86_64", family: "mac"
2. So, where is Maven installed?
A quick check with whereis command :
$ whereis mvn /usr/bin/mvn
$ cd/usr/bin
$$ ls -ls |grep mvn
8 lrwxr-xr-x 1 root wheel 24 May 23 15:57 mvn ->/usr/share/maven/bin/mvn
By default, Maven is installed at /usr/share/maven.
3. Change Maven local repository
A common post-installation for Maven, change the local repository to another location.
$sudovim/usr/share/maven/conf/settings.xml
settings.xml
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <localRepository>/Users/mkyong//maven/repo/</localRepository>
Above example changed the default repository from ~/.m2/repository to /Users/mkyong//maven/repo/.
Note
For older Mac OS, you need to download, extra, and configure the environment manually. Please refer to this guide.