2.5. Maven Installation Details
Maven’s download measures in at a few megabyte only. It has attained such
a slim download size because the core of Maven has been designed to
retrieve plugins and dependencies from a remote repository
on-demand. When you start using Maven, it will start to download
plugins to a local repository described in
Section 2.5.1, “User-Specific Configuration and Repository”. In case you are curious, let’s take a
quick look at what is in Maven’s installation directory.
/usr/local/maven $ ls -p1
LICENSE.txt
NOTICE
README.txt
bin/
boot/
conf/
lib/
LICENSE.txt
contains the software license for Apache Maven. The lib/
directory contains a the JAR files that contains the core of Maven.
Note
Unless you are working in a shared Unix environment, you should
avoid customizing the settings.xml
in conf
. Altering the
global settings.xml
file in the Maven installation itself is usually
unnecessary and it tends to complicate the upgrade procedure for Maven
as you’ll have to remember to copy the customized settings.xml
from
the old Maven installation to the new installation. If you need to
customize settings.xml
, you should be editing your own
settings.xml
in ~/.m2/settings.xml
.
2.5.1. User-Specific Configuration and Repository
Once you start using Maven extensively, you’ll notice that Maven has
created some local user-specific configuration files and a local
repository in your home directory. In ~/.m2
there will be:
-
~/.m2/settings.xml
-
A file containing user-specific configuration for authentication,
repositories, and other information to customize the behavior of
Maven.
-
~/.m2/repository/
-
This directory contains your local Maven repository. When you
download a dependency from a remote Maven repository, Maven stores
a copy of the dependency in your local repository.
Note
In Unix (and OS X), your home directory will be referred to using
a tilde (i.e. ~/bin
refers to /home/tobrien/bin
). In Windows, we
will also be using ~
to refer to your home directory. In Windows XP,
your home directory is C:\Documents and Settings\tobrien
, and in
Windows Vista, your home directory is C:\Users\tobrien
. From this
point forward, you should translate paths such as ~/m2
to your
operating system’s equivalent.
2.5.2. Upgrading a Maven Installation
If you’ve installed Maven on a Mac OS X or Unix machine according to
the details in Section 2.3.1, “Installing Maven on Linux, BSD and Mac OS X”, it should be easy to upgrade to
newer versions of Maven when they become available. Simply install the
newer version of Maven (/usr/local/maven-3.future) next to the
existing version of Maven (/usr/local/maven-3.0.3). Then switch the
symbolic link /usr/local/maven
from /usr/local/maven-3.0.3
to
/usr/local/maven-3.future
. Since you’ve already set your PATH
variable to point to /usr/local/maven
, you won’t need to change any
environment variables.
If you have installed Maven on a Windows machine, simply unpack Maven
to C:\Program Files\maven-3.future
and update your PATH
variable.
Note
If you have any customizations to the global settings.xml
in
conf
, you will need to copy this settings.xml
to the
conf
directory of the new Maven installation.