Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Introduction to Apache Maven 2

Sing Li (, Author, Wrox Press
Photo of Sing Li
Sing Li is a consultant and an active author with more than two decades of industry experience. He has contributed to Professional Apache Geronimo, Beginning JavaServer Pages, Professional Apache Tomcat 5, Pro JSP - Third Edition, Early Adopter JXTA, Professional Jini, Beginning J2ME: From Novice to Professional, Third Edition, Professional Apache Geronimo, and numerous other books. Sing also writes for technical magazines and participates in open source communities. He is an evangelist of the open source, VOIP, and P2P movements. You can reach Sing at

Summary:  Modern software projects are no longer solely monolithic creations of single local project teams. With the increased availability of robust, enterprise-grade open source components, today's software projects require dynamic collaboration among project teams and often depend on a mix of globally created and maintained components. Now in its second generation, the Apache Maven build system -- unlike legacy build tools created before the Internet-enabled era of global software development -- was designed from the ground up to take on these modern challenges. This tutorial gets you started with Maven 2.

Date:  19 Dec 2006
Level:  Intermediate

Activity:  152623 views

Repositories and coordinates

Maven 2 repositories store a collection of artifacts used by Maven during dependency resolution for a project. Local repositories are accessed on the local disk, and remote repositories are accessed through the network.

An artifact is usually bundled as a JAR file containing the binary library or executable. This is known as an artifact's type. In practice, however, an artifact can also be a WAR, EAR, or other code-bundling type.

Maven 2 takes advantage of an operating system's directory structure for quick indexing of the collection of artifacts stored within a repository. This repository index system relies on the ability to identify any artifact uniquely via its coordinate.

Maven coordinates

A Maven coordinate is a tuple of values that uniquely identifies any artifact. A coordinate comprises three pieces of information:

  • The group ID: The entity or organization responsible for producing the artifact. For example, can be a group ID.

  • The artifact ID: The name of the actual artifact. For example, a project with a main class called OpsImp may use OpsImp as its artifact ID.

  • The version: A version number of the artifact. The supported format is in the form of mmm.nnn.bbb-qqqqqqq-dd , where mmm is the major version number, nnn is the minor version number, and bbb is the bugfix level. Optionally, either qqqqq (qualifier) or dd (build number) can also be added to the version number.

Maven coordinates are used throughout Maven configuration and POM files. For example, to specify a project dependency on a module entitled OpsImp at the 1.0-SNAPSHOT level, a pom.xml file includes the segment shown in Listing 1:

Listing 1. Maven coordinate for an example OpsImp module

The special SNAPSHOT qualifier tells Maven 2 that the project or module is under development and that it should fetch the latest copy of the artifact available.

To specify that the project depends on JUnit for unit testing, JUnit 3.8.1's coordinates can be added as a dependency in the project's pom.xml, as shown in Listing 2:

Listing 2. Maven coordinate for a JUnit dependency

Looking into a Maven repository

Because Maven repositories are ordinary directory trees, you can readily take a look at how artifacts are stored on disk. Figure 3 is a portion of the local repository, showing the location of the JUnit 3.8.1 artifact:

Figure 3. Inside a Maven 2 repository
Inside a Maven 2 repository

In Figure 3, you can see that Maven maintains an artifact's POM file, together with checksum hashes for both the artifact and its POM in the repository. These files help ensure artifact integrity when artifacts are transferred between repositories. This artifact has been downloaded from the central repository and placed into the local repository by Maven's dependency management engine.

In Figure 4, the artifact with coordinates is shown in the local repository. The artifact is in the directory together with the POM file. In this case, the artifact is installed locally.

Figure 4. OpsImp artifact in a local repository
OpsImp artifact in a local repository

4 of 15 | Previous | Next


Zone=Java technology, Open source
TutorialTitle=Introduction to Apache Maven 2