Safeguard
Developer Tools•

How do I see why Gradle picked a dependency version?

Use the Gradle dependencyInsight task to list every path to a dependency and why its version was chosen, then fix the version that carries the flaw.

Safeguard Security Team
3 min read

Run the dependencyInsight task with the dependency name and a configuration. Gradle prints every path that leads to the dependency and a selection reasons section that explains why that version won, such as conflict resolution, a constraint or a forced version. Use it to decide which requirement to change when a scan flags a version.

Definitions

Configuration. A named set of dependencies, such as compileClasspath or runtimeClasspath.

Conflict resolution. The rule Gradle uses to choose one version when several are requested.

Constraint. A rule that influences the selected version without adding a dependency by itself.

Two tasks to know

The dependencies task renders a tree for every configuration of a project, with the selected version and conflict resolution details. In its output, an asterisk marks a repeated subtree shown once in full, and a letter c marks a constraint.

The dependencyInsight task answers a narrower question. It needs a dependency, as a full group and name or a partial match, and a configuration. In Java projects the configuration defaults to compileClasspath. Optional switches show a single path or all variants.

./gradlew -q dependencies --configuration runtimeClasspath
./gradlew -q dependencyInsight --dependency commons-codec --configuration runtimeClasspath

Selection reasons you will see

Reason in the reportWhat it meansWhat you can change
Was requestedA direct or transitive declaration asked for itThe declaring dependency
By conflict resolutionSeveral versions were asked for, one wonRaise the lowest request, or add a constraint
By constraintA constraint influenced itThe constraint
By ancestorA strict version from a parent enforced itThe parent
Selected by ruleA resolution rule overrode the defaultThe rule
ForcedA platform or strategy set itThe platform or strategy

Steps for a flagged version

  1. Take the group, name, and vulnerable version from the scan.
  2. Pick the configuration that ships, usually runtimeClasspath.
  3. Run dependencyInsight and read all paths.
  4. Check the selection reason. If it was conflict resolution, a constraint on the fixed version may be enough.
  5. If a rule or strict version forces it, change that rule.
  6. Rebuild, rerun the task, and confirm the new version.
  7. Re-scan.

Tips

  • Check each configuration that matters, since test and runtime sets differ.
  • Prefer a constraint with a because note, so the next person understands it.
  • Do not use a forced version without a comment and a review date.

Try it yourself

Click through it at your own pace, or open it full screen.

Expand the inventory and trace which direct dependency brings in a given package.

Quick check

Why does the same library appear at two versions in my tree?

Different configurations, or different requests that Gradle resolved to one version. The insight report shows the paths and the reason.

Should I force a version to fix a finding?

As a last step. A constraint or a parent upgrade is cleaner and easier to review.

Safeguard SBOM and dependency scanning covers Java builds and ranks findings by whether your code reaches them. Run a free scan on a repository.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.