Monday, 24 February 2014

Installing Apache Maven on Mac OS X

Well, all new Mac machines loaded with Lion and above, come pre-installed with Maven. In order to find out which version is installed on your machine by default, just type the following in terminal :

mvn -version

Mine came pre-loaded with v3.0.3 and the default Maven Home was set at /usr/share/maven

However you if want to upgrade the version or configure the Maven Home to a different location, perform the following steps :

  • After downloading, unzip it and copy the entire folder to some other directory. Let's say for instance - /usr/lib/apache-maven-3.2.1
  • We now need to a couple of environment variables to our bash profile. In terminal, type vi ~/.bash_profile and insert the following variables to it ( i for insert ).
  • Now lets add the environment variable M2_HOME so type export M2_HOME=/usr/lib/apache-maven-3.2.1
  • Also define the M2 environment variable so type export M2=$M2_HOME/bin
  • Next type export PATH=$M2:$PATH and save .bash_profile and quit ( :wq )
  • Finally type source ~/.bash_profile. Note that when you close and open a new shell, the same settings will be intact.
Confirm the new settings by typing mvn -version to see the updated Maven version and home.
Congratulations, you just customised Maven on your machine. 

Just as am writing this post, am thinking about some stuff about Nexus repository manager which will enable you to manage your Maven repositories. Never mind, I'll cover Nexus in another upcoming post. Stay tuned :)

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker