This is a quick installation guide to Apache Maven on a Mac, using the Terminal and the command line. Estimated duration: 15 minutes.
Apache Maven is a software build, management and comprehension tool. Based on the concept of a project object model (POM, materialized as an XML file), Maven can manage a project’s build, reporting and documentation from a central piece of information. It can save you precious time when you have to manage all your external Java libraries (JAR).
Environment
- Mac OS X 10.9.1 (13B42) – Mavericks
- Apache Maven 3.1.1
- Java 1.7
Downloads
Apache Maven can be downloaded from http://maven.apache.org/download.cgi.
Installation
Type in the following commands:
$ sudo mkdir /usr/local/apache-maven $ cd /usr/local/apache-maven $ sudo cp /Users/jgp/Downloads/apache-maven-3.1.1-bin.zip . $ sudo unzip apache-maven-3.1.1-bin.zip $ ls -l total 12304 drwxr-xr-x 9 root wheel 306 Sep 17 11:24 apache-maven-3.1.1 -rw-r--r-- 1 root wheel 6297277 Feb 20 14:12 apache-maven-3.1.1-bin.zip
Modify the bashrc file:
$ sudo vi /etc/bashrc
Add (esc, :$ (enter), $, a (enter), paste):
export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1 export M2=$M2_HOME/bin export MAVEN_OPTS="-Xms256m -Xmx512m" export PATH=$M2:$PATH export JAVA_HOME=`/usr/libexec/java_home -v 1.7` export PATH=$JAVA_HOME/bin:$PATH
Save (esc, :w! (enter), :q (enter)).
Checking
Run, in a new tab in terminal or a new terminal. This is to make sure that the bashrc file has been reloaded.
$ mvn -version Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 11:22:22-0400) Maven home: /usr/local/apache-maven/apache-maven-3.1.1 Java version: 1.7.0_51, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"
Cleanup
Delete the remaining zip file.
$ sudo rm /usr/local/apache-maven/apache-maven-3.1.1-bin.zip
Comments are closed.