Fork me on GitHub

Compare dependency versions

The compare-dependencies goal can be used to compare the dependencies in the current project to the dependencyManagement of a remote project. This is useful, for example, for finding differences between the current project dependencies and an organizational bill of materials (BOM) pom. You specify the remote groupId, artifactId, and the version to which the current project should be compared, for example

mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0

By default the list of dependency differences will be output to the command line. This can be written to a file using the “reportOutputFile” parameter.

mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DreportOutputFile=${project.build.directory}/depDiffs.txt

The plugin can also automatically update the dependencies of the current project to match the remote project using the “updateDependencies” parameter. By default this is turned off.

mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DupdateDependencies=true

In addition to that, any property defined in the current project that represent the version of one of several artifacts can be updated to match the remote project using the “updatePropertyVersions” parameter. By default this is turned off.

mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -updatePropertyVersions=true

Such update will only occur if the dependencies linked to that version exist in the remote project and all these dependencies have a single version. In any other case, the property is not updated.