Recently I upgraded my Mac OS X to Mavericks (10.9) and I was surprised to see that it doesn’t come with Maven. Earlier versions of Mac OS X such as Lion and Mountain Lion used to have maven installed by default.
There are some third party options such as HomeBrew and using XCode to install Maven on Mac OS X Mavericks but I wanted to do it myself without relying on another software for getting maven working.
Here are the steps that I used to install maven on Mac OS X Mavericks.
Step 1: Download Maven binaries from Maven Download Page. I was using Maven 3.0.5, so I downloaded apache-maven-3.0.5-bin.tar.gz.
Step 2: You can install Maven at any location but since it’s a one time process, I didn’t wanted it in my user directory. So I installed it in /usr/local directory. You might have to use sudo command to install in /usr/local directory if you are getting permission denied error.
$ cd /usr/local $ sudo mv /Users/pankaj/Downloads/apache-maven-3.0.5-bin.tar.gz ./ $ sudo tar -xvf apache-maven-3.0.5-bin.tar.gz
Step 3: Now open the bash profile file and add following lines into it. Usually profile file names are .bash_profile or .profile, use whichever you have in your system. If you don’t have profile file, you will have to create one with vi command.
$ cd $HOME $ vi .bash_profile #Add below lines in the profile export M2_HOME=/usr/local/apache-maven-3.0.5 export PATH=$PATH:$M2_HOME/bin #save and quit $ source .bash_profile
That’s it, maven is installed on your latest Mac OS X and you can verify it by issuing below command.
$ mvn --version Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28-0800) Maven home: /usr/local/apache-maven-3.0.5 Java version: 1.7.0_09, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
You can use this method to install any maven version you would like to use and at your specified location.
Let me know if you find any issues with above setup steps.