Maven installation and configuration for Windows
|
|
|
This document describes how to install and setup Maven step by step.
Requirement
| Java JDK | 1.5 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's) |
| Memory | No minimum requirement |
Get the binary
The latest version can be found at http://maven.apache.org/download.html . The downloaded install archive contains everything required to run Maven on your system.
Maven 3.0.3 (Binary zip) apache-maven-3.0.3-bin.zip
Unpack
You can now unpack the install archive. It is recommended to install it in a folder without spaces, quotes and special characters in it. I recommend short name like :
Extract your zip file in <Drive Letter>:\opt. You will get the following directory :
If you love like me the power of the symbolic links you can use the following command on Windows Vista or 7 (Run a Dos prompt as Administrator)
You have know a clean installation.
Using symbolic you can perform an upgrade by updating the symbolic link.
You should have the following structure in the folder :
Define the environment variables settings
| Variable Name | Value |
|---|---|
| M2_HOME | c:\opt\maven |
f you don't have the JAVA_HOME variable defined create one with the location of your JDK
| Variable Name | Value |
|---|---|
| JAVA_HOME | e.g : C:\opt\Java\jdk1.6.0_23 |
Add the Maven /bin directory to your PATH variable using the variable M2_HOME
Define local repository
The location of your local repository can be changed in your user configuration. The default value is ${user.home}/.m2/repository/ . I strongly recommend to change this location due to the fact that your home is presumably backed up or will be and the size of your home folder can be restricted by the system administrator.
We will change that location in the settings.xml file located in our maven installation folder. The file should be located in :
Create the following folder
Note: The local repository must be an absolute path.
Content change
Configuring proxy
This part is not covered yet¨
Configure Maven to use Nexus (Optional)
Nexus is a maven repository manager. You can use Nexus to host your own maven repository for artifact created in your company, or for caching external artifacts.
If you don't have a nexus server in your organisation you can skip this section.
To use Nexus, you will configure Maven to check Nexus instead of the public repositories. To do this, you'll need to edit your
settings.xml
file.
We have defined a single profile: nexus.
The nexus profile is configured to download from the central repository with a bogus URL of http://central. This URL is overridden by the mirror setting in the same settings.xml file to point to the URL of your single Nexus group. The nexus group is then listed as an active profile in the activeProfiles element.

Test your installation
Open a dos prompt and execute
Result
Tips and Tricks
Non modifiable m2_repo variable
If you are facing problem with the m2_repo variable not modifiable in Eclipse (non modifiable m2_repo variable)
You can define a symbolic link in windows to create a link to your settings file in your maven installation folder
Run a doc command as administrator