Repository
II. Repository
Another concept in Maven is that of a repository. The
repository holds the artifacts on which your project depends. There are two
kinds of repository: local and remote. Both of them can be declaratively set.
Unless specified otherwise, the local repository is created in a special
directory called ".m2/repository". In Windows, this
directory is created in C:\Documents and Settings\Administrator. For example, if your
project depends on commons-logging version 1.0.4, you can specify the dependency
in pom.xml and when maven is executed, it will copy the appropriate
commons-logging jar file from the remote repository to the local repository and
then use it to build your project's artifact like JARs, WARs, EARs etc.
The maven repository folder has
subfolders for each library. For instance, there is a sub folder for
commons-logging. Beneath the commons-logging folder there is another subfolder
called jars. This jars folder has the commons logging jar files suffixed by
version number.
The role of the repository is immediately obvious. Instead of each project
having its own copies of third party libraries, the repository helps developers
across projects to share the libraries. Each project can also in turn generate
its artifacts and publish it into the remote repository. The process of
publishing a jar into the repository is called "install" in
Maven lingo. This install process helps organizations to share internal
artifacts across projects in a standard manner. This also holds the basis for
continuous integration among inter-dependent projects.
Figure shows the pom.xml, repository and plugins. The grey colored rectangles are provided by you. The
blue colored rectangles are provided by Maven. The orange colored rectangle shaded is the
output - the real deployment artifact obtained for your project. Custom
plug-ins are optional. The rest of the inputs are mandatory.
Click to learn more about Maven2 Repository
Setting Up A Maven2 Repository