Download, Install and Setup Maven
Maven is a build management tool. It will come handy when we have lots of dependencies, we keep on updating the dependent project, complex build version management. ANT is there for long as a build tool and is popularly used in development. So why do we need Maven?
Maven vs ANT
- ANT focuses only on building a project. Wherein Maven focuses on dependency management and build management.
- ANT is simple, easy to learn and use. With just few basic commands, we are up and running in ANT. In comparison with ANT, Maven is difficult for a novice to understand and use.
- Maven project’s follow a folder structure, this convention makes sharing projects between different IDEs easier.
- Maven has a build lifecycle convention like compile –> package –> install (approx. for understanding). In ANT, we need to explicitly define goals/targets for these standard objectives too.
- In general ANT project does not rely or link to external dependencies outside the project. With Maven, on first use the dependencies have to be downloaded from a repository.
- There are popular public repositories available for Maven and downloading common jars is easier. With ANT, for shared projects we need to scout for the dependent jars one by one unless they are bundled.
My personal choice depends on the nature of project, considering facts like below
- if I will be collaborating with multiple persons
- are there multiple number of dependent jars and their size
- is the dependent jar a rare find
- is it a simple test project, just build, test and dump
I am writing this article now because going forward I will be using Maven to build some of the tutorial example projects instead of ANT. In that case, this tutorial might help you to setup Maven. If you are behind a proxyserver which blocks access to Maven repositories, then you have to talk to your IT admin to enable access.
I assume you have already JDK installed.
Step 1: Download Maven
http://maven.apache.org/download.cgi is the link to download Maven. ANT and Maven both are by Apache Software Foundation.
Click and download the ‘Binary Zip’ (Ex: apache-maven-3.1.0-bin.zip) file from the ‘current stable’ version.
Step 2: Install Maven
Maven does not uses an executable file to install. It is just a zip file. Just unzip it to a folder in the hard disk.
Step 3: Setup Maven
1. Add environment variable MAVEN_HOME to the path where you extracted the maven binary zip file.
2. Add path variable, so that we can execute ‘mvn’ command from any location in command prompt.
Verify if you have done everything right,
This JEE tutorial was added on 03/10/2013.