Download Maven 3
Maven is a very popular project management tool that can be run either from a command-line window using simple text commands or directly from the Eclipse IDE itself, using the Maven2Eclipse (m2e) plugin. The Maven Users Center provides a nice overview of working with this tool. Installation steps:
-
Download and uncompress the latest Maven release version from the Apache Maven site.
-
Create a $MAVEN_HOME operating system environment variable pointing to the base directory of Maven, and add the $MAVEN_HOME/bin directory to your system path so you can easily execute Maven commands from any command-line directory.
-
Add the M2_REPO classpath variable to your Eclipse IDE. Maven downloads source code JARs needed by your projects to your computer, storing them in what is called your local Maven repository, normally the hidden .m2\repository folder in your home directory (i.e., under /home/myusername for Linux or C:\Documents and Settings\myusername on Windows). Eclipse needs to know this location to load dependencies. To add this variable, start Eclipse, and from the menu bar, select Window | Preferences | Java | Build Path | Classpath Variables and define an M2_REPO variable pointing to your local repository folder.
-
If you installed Tomcat in the previous step, you'll want to edit the $MAVEN_HOME/conf/settings.xml file to add in the Tomcat username and password you configured above, i.e.:
<servers> <server> <id>myTomcat</id> <username>tomcat</username> <password>tomcat</password> </server> ... other server configurations ... </servers>
The myTomcat ID above (any other ID can also be used) is used within Maven pom.xml files to identify the specific server username/password combination when deploying applications to various application servers, in this case Tomcat. As an alternative, this information can be directly configured within each Maven project's pom.xml file whenever you will be doing Tomcat deployment.
-
Next let's test your Maven installation. Run mvn version from any command-line prompt. You should see Maven respond providing the Maven version you downloaded, the JDK version, and various other associated information.