Skip to content
Latchkey

mvn dependency:tree: Usage, Options & CI Errors

See the whole transitive graph - and exactly who pulls in that library.

dependency:tree is a goal of the maven-dependency-plugin that prints the project’s dependencies as a tree, including transitive ones and how Maven resolved version conflicts. It is the first tool to reach for when debugging a dependency clash.

What it does

dependency:tree walks the resolved dependency graph and prints it hierarchically, marking omitted/conflicting versions. With -Dverbose it shows conflicts that mediation removed; with -Dincludes it filters to a single coordinate to find who brings it in.

Common usage

Terminal
mvn dependency:tree
mvn dependency:tree -Dverbose
mvn dependency:tree -Dincludes=com.fasterxml.jackson.core:jackson-databind
mvn dependency:tree -DoutputFile=tree.txt

Common error in CI (and the fix)

Symptom: a NoSuchMethodError or NoClassDefFoundError at runtime from conflicting versions of the same library. Cause: two transitive paths request different versions and Maven’s nearest-wins mediation picked one that is incompatible. Fix: run dependency:tree -Dverbose -Dincludes=group:artifact to find both paths, then pin the wanted version in <dependencyManagement> or add an <exclusion> on the offending path.

Using this in CI

  • Set the shell explicitly and enable set -euo pipefail; the default runner shell does not stop on the first error inside a multi-line block.
  • Pin the tool version. An unpinned build tool turns a runner image update into a build break on unchanged code.
  • Prefer non-interactive and batch flags. Progress output designed for a terminal bloats CI logs and can hang without a TTY.
  • Write machine-readable output (JSON, JUnit) to a file and upload it as an artifact, so a failure is diagnosable without re-running the job.

Frequently asked questions

mvn dependency:tree: Usage, Options & CI Errors?
dependency:tree is a goal of the maven-dependency-plugin that prints the project’s dependencies as a tree, including transitive ones and how Maven resolved version conflicts. It is the first tool to reach for when debugging a dependency clash.
What it does?
dependency:tree walks the resolved dependency graph and prints it hierarchically, marking omitted/conflicting versions. With -Dverbose it shows conflicts that mediation removed; with -Dincludes it filters to a single coordinate to find who brings it in.
Common error in CI (and the fix)?
Symptom: a NoSuchMethodError or NoClassDefFoundError at runtime from conflicting versions of the same library. Cause: two transitive paths request different versions and Maven’s nearest-wins mediation picked one that is incompatible.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card