Project Relationships

One of the compelling reasons to use Maven is that it makes the process of tracking down dependencies (and dependencies of dependencies) very easy. When a project depends on an artifact of another project, we can say that this artifact is a dependency. In the case of a Java project, this can be as simple as a project depending on an external dependency such as Log4J or JUnit. Although dependencies can model external dependencies, they can also manage the dependencies between a set of related projects; if project-a depends on project-b, Maven is smart enough to know that project-b must be built before project-a.

Relationships are not only about dependencies and figuring out what one project needs to be able to build an artifact. Maven can model the relationship of a project to a parent, and the relationship of a project to submodules. This section gives an overview of the various relationships between projects and how such relationships are configured.

More on Coordinates

Coordinates define a unique location for a project. They were first introduced in Chapter 3. Projects are related to one another using Maven coordinates. project-a doesn’t just depend on project-b; a project with a groupId, artifactId, and version depends on another project with a groupId, artifactId, and version. To review, a Maven coordinate is made up of three components:

groupId

A groupId groups a set of related artifacts. Group identifiers generally resemble a Java package name. For example, ...

Get Maven: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.