LinuxCommandLibrary

gradle-dependencies

Display project dependency tree

TLDR

Display all dependencies

$ gradle dependencies
copy

Display dependencies for a specific configuration
$ gradle dependencies --configuration [implementation]
copy

Display dependencies for a specific subproject
$ gradle :[subproject]:dependencies
copy

Display dependencies and save to a file
$ gradle dependencies > [path/to/dependencies.txt]
copy

SYNOPSIS

gradle dependencies [configuration-name] [--configuration name] [gradle-options]

PARAMETERS

--configuration
    Limits output to a specific configuration (e.g., compileClasspath, testRuntimeClasspath)

--scan
    Creates a shareable build scan with interactive dependency graph

-q, --quiet
    Log level quiet; suppresses non-error output

--info
    Enables info-level logging for dependency resolution details

--configuration-cache
    Uses configuration cache for faster repeated runs

--no-build-scan
    Disables automatic build scans

-P=
    Passes system properties affecting dependency resolution

DESCRIPTION

The gradle dependencies command is a core Gradle task that outputs a hierarchical view of all dependencies for a project's configurations. It reveals direct and transitive dependencies, helping developers identify version conflicts, unused libraries, and resolution details.

Run it in a Gradle project root to see trees for every configuration (e.g., implementation, testImplementation). Each tree shows modules with group:artifact:version format, indented to indicate nesting. Exclusions and substitutions are highlighted.

This aids in dependency management, auditing security vulnerabilities, and optimizing builds by spotting bloated deps. Supports multi-project builds, displaying per-subproject trees. Output is console-friendly but verbose; pipe to files for analysis.

Ideal for CI/CD pipelines to enforce dependency policies or generate reports.

CAVEATS

Requires Gradle project directory with build.gradle(.kts); verbose output for large projects; does not resolve dynamic versions without --refresh-dependencies.

EXAMPLE USAGE

gradle dependencies --configuration implementation
gradle testRuntimeClasspath dependencies --scan

OUTPUT PARSING

Use gradle dependencies > deps.txt then grep/search for analysis; integrates with tools like DepsGraph or Gradle Dependency Insight plugin.

HISTORY

Introduced in Gradle 0.1 (2007) by Hans Dockter; evolved with configuration API in 1.0 (2012), build scans in 3.6 (2017), and configuration cache in 6.6 (2020) for performance.

SEE ALSO

gradle(1), gradle tasks(1), mvn dependency:tree(1)

Copied to clipboard