Sunday, July 1, 2012

Apache Maven - Setting up

What is Apache Maven?

In simple words Maven is a build automation tool for Java projects. 
There are many things which can be written for maven but to get more theoretical details  visit Apache Maven-Wikipedia page or can refer to the official Apache Maven website.


Setting-up Apache Maven:

Setup - Windows:

  1. First download the latest version maven form here. For this tutorial, I have downloaded maven-3.0.4.
  2. Unzip the downloaded apache-maven-3.0.4-bin.zip. In my case, unzipped it in C:\dev\maven3.0.4.
  3. Set a new environment variable M2_HOME pointing to the directory where maven is installed or  unzipped. In case if you don't know how to set an environment variable in windows, follow the link
  4. Set another environment variable M2 with value %M2_HOME%\bin. In the same way create/update the PATH variable with value %M2% so that Maven can be accessed from command line. 
  5. Check if the PATH variable also has the value of JAVA_HOME pointing to the installed jdk.
  6. Open command prompt (WinKey + R and type cmd) and execute the command mvn --version to see if its installed well.

Setup - Eclipse:


For this there is a plugin for Eclipse called M2E which can be used to launch Maven builds from within Eclipse and other stuff which maven can do.
Follow the steps given below to get M2E on eclipse:
  1. Open Eclipse.
  2. From the eclipse menu list, go to help -> Install New Software...
  3. Get maven from the update site "maven - http://download.eclipse.org/technology/m2e/releases".
    • Add the maven update site and get the list of plugins provided by it.
    • Select the plugin Maven Integration for Eclipse and press next and next.
    • Read and accept the terms of license agreement and press finish.


    • Restart eclipse.

More on Maven:

Feel free to share your experience/issues. 

No comments: