# Dependency Management

version 8.1

Software projects rarely work in isolation. Projects often rely on reusable functionality from libraries. Some projects organize unrelated functionality into separate parts of a modular system. Dependency management is an automated technique for declaring, resolving and using functionality required by a project.

| For an overview of dependency management terms, see Dependency Management Terminology.

## Dependency Management in Gradle

Gradle has built-in support for dependency management.

We’ll explore the main concepts with the help of the theoretical but common project to define terms:

- This project builds Java source code.

- Some of the Java source files import classes from Google Guava, a open-source library.

- This project uses JUnit for testing.

This project uses Guava and JUnit as dependencies. Gradle fetches dependencies from repositories. You can declare repositories to tell Gradle where to fetch dependencies. Repositories offer dependencies in multiple formats. For information about the formats supported by Gradle, see dependency types.

A build script developer can declare dependencies for different scopes. For example, Gradle could use one scope to compile source code and another to execute tests. Gradle calls the scope of a dependency a configuration.

During a build, Gradle locates the dependencies needed for the requested tasks. The dependencies might need to be downloaded from a remote repository, retrieved from a local directory, or (in a multi-project setting) built from another project. This process is called dependency resolution. For more information, see How Gradle downloads dependencies.

Gradle stores resolved dependencies in a local cache called the dependency cache. Subsequent builds use the cache to avoid unnecessary network calls.

Metadata describes dependencies. Some examples of metadata include:

- coordinates for finding the dependency in a repository

- information about the project that created the dependency

- the authors of the dependency

- other dependencies required for a dependency to work properly, known as transitive dependencies

You can customize Gradle’s handling of transitive dependencies based on the requirements of a project.

Projects with tens or hundreds of declared dependencies can be difficult to debug. Gradle provides tooling to visualize and analyze a project’s dependency graph. You can use a build scan or built-in tasks. For more information, see Viewing and Debugging Dependencies.

Figure 1. Build scan dependencies report