码迷,mamicode.com
首页 > 系统相关 > 详细

Mac上安装 Maven

时间:2015-08-28 21:16:00      阅读:431      评论:0      收藏:0      [点我收藏+]

标签:

http://www.tuicool.com/articles/ZV3yUn

 

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

Mac上安装 Maven

标签:

原文地址:http://www.cnblogs.com/wind90/p/4767863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!