Introduction to MavenMaven is a simple build automation tool which is basically used with java projects. Maven is also defined as a comprehensive project management tool. It aims to provide the developers a complete and detailed build life cycle framework of an application.

Maven also ease up the task of developers in checking a build status, generating reports (basically javadocs) and setting up the automated build process and monitor the same.

The ease of source code compilation, distribution, documentation, collaboration with different teams and other vital tasks are seamless by using maven.

Maven aims to describe 2 important things :

How a software is built.
The dependencies, plug-ins & profiles that the project is associated in a standalone or a distributed environment.
The maven can also be used in building & managing the projects written using C#, ruby and other programming languages as well.

Advantages of Using Maven over Ant

>Managing dependencies.
> Convention over configuration – configuration is very minimal
> Multiple/Repeated builds can be achieved.
> Focus on automation.
>Plugin management.
>Testing – ability to run JUnit and other integration test suites.
>Making the development process transparent.
>Provision to check the status of each build.
>Avoiding inconsistent setups.
>Standard and uniformed infrastructure among projects.

Setting up Maven Environment
Maven is one of the handy tool which can be set up quickly and can be made it ready for any java projects within a max of 10 minutes. Also, the maven downloadable package is also very light weight. Follow the below mentioned steps in order to download and set up the maven in the windows environment.


Download the latest version of the maven from website.


NOTE : Any version of the maven which is above 3.2 requires JDK version to be 1.6 and above.


Once the download is successful. Unzip the downloaded maven zip and place it in a drive containing all the java related artifacts. E.g. D:\Java\apache-maven-3.2.5 , in case you have downloaded any other latest release than the version may differ, but thats not a problem.



Now we need to set up the class path Java (JAVA_HOME) and Maven (M2_HOME). If you already have JAVA_HOME set, then you only need to set M2_HOME for Maven. Kindly ensure that the required version of the jdk has been installed.


Now edit the variable Path in the System variables to include the JAVA_HOME and M2_HOME.



If the above steps are carried out successfully, then we are done with the installation and setup process of the maven tool. Now in this final step, we would be verifying for the same and ensure things are fine accordingly.

Just open up the command prompt from the Start -> Command Prompt and in the command prompt just type the maven command mvn -version and press enter. It will display the results as shown below and confirms that our maven setup is successful and completed.


What is Repositories in Maven?
For maven to download the required artifacts of the build and dependencies (jar files) and other plugins which are configured as part of any project, there should be a common place where all such artifacts are placed. This common shared area is called as Repository in maven.

In maven, repositories are classified into 3 main categories as shown below :

Local Repository
Remote Repository
Central Repository
Local Repository

The repository which resides in our local machine which are cached from the remote/central repository downloads and ready for the usage. The folder to hold/place all the dependencies in local can be configured in the settings.xml file of the maven folder under the tag <localRepository>.


Remote Repository

This repository as the name suggests resides in the remote server and which can be accessed by using different file transfer protocols like file:// or http://. Remote repository will be used for both downloading and uploading the dependencies and artifacts.


Central Repository

This is the repository provided by maven community. This repository contains large set of commonly used/required libraries for any java project. Basically, internet connection is required if developers want to make use of this central repository. But, no configuration is required for accessing this central repository.