Dependency Management
About
This category includes plugins that help manage how dependencies are resolved, downloaded, analyzed, and maintained within a Maven project. These plugins assist with inspecting the dependency tree, resolving conflicts, managing transitive dependencies, enforcing dependency constraints, and working with repositories.
These tools are especially useful for large or complex projects with many modules or dependencies, where tracking and controlling dependency versions and scopes is critical.
Maven Dependency Plugin
The Maven Dependency Plugin (maven-dependency-plugin
) is a key tool for analyzing, resolving, and manipulating project dependencies. It offers a rich set of goals to help us understand the dependencies in our project, copy them, unpack them, or list their structure.
Common Goals
dependency:tree
Shows the dependency hierarchy (useful for conflict resolution)
dependency:list
Lists all dependencies used in the project
dependency:copy
Copies specific dependencies to a folder
dependency:copy-dependencies
Copies all project dependencies
dependency:unpack
Unpacks dependency JARs into specified directories
dependency:analyze
Analyzes unused or undeclared dependencies
dependency:purge-local-repository
Removes specific artifacts from the local repository to force fresh download
Plugin Configuration
Example
Versions Maven Plugin
The Versions Maven Plugin (versions-maven-plugin
) helps manage versions of dependencies, plugins, and even the parent POM. It is especially useful for identifying outdated dependencies and suggesting updates.
Common Goals
versions:display-dependency-updates
Lists available newer versions of dependencies
versions:use-latest-versions
Replaces current versions with the latest available
versions:use-next-releases
Updates to the next release version only (no SNAPSHOT)
versions:lock-snapshots
Converts all SNAPSHOT dependencies to specific versions
Plugin Configuration
Example
Maven Install Plugin
The Maven Install Plugin (maven-install-plugin
) is responsible for installing our project's artifacts (e.g., JARs, POMs) into the local Maven repository (~/.m2/repository
) so they can be reused by other local projects.
This plugin is automatically bound to the install
phase of the build lifecycle.
Goal
install:install
Installs the project artifact into the local repository
Plugin Configuration
Example
This will:
Compile the code
Run tests
Package the artifact (JAR/WAR)
Install it to your local repository
Maven Deploy Plugin
While more common in release workflows, the Maven Deploy Plugin (maven-deploy-plugin
) is closely related to dependency management because it handles publishing artifacts to a remote repository, making them available as dependencies in other projects.
It works with remote repositories like Nexus or Artifactory.
Goal
deploy:deploy
Uploads project artifacts to a remote repository
Plugin Configuration
Example
We must configure distributionManagement
in pom.xml
and authentication credentials in settings.xml
.
Last updated
Was this helpful?