# Dependency Resolution Basics

version 8.12

Dependency resolution in Gradle can largely be thought of as a two-step process.

First, the graph resolution phase constructs the dependency graph based on declared dependencies. Second, the artifact resolution phase fetches the actual files (artifacts) for the resolved components:

1. Graph resolution phase:

   - Driven by declared dependencies and their metadata

   - Uses the request attributes defined by the configuration being resolved

2. Artifact resolution phase:

   - Based on nodes in the resolved dependency graph

   - Matches each node to a variant and an artifact

The outcome of these processes can be accessed via different APIs, each designed for specific use cases.

## 1. Graph Resolution

During the graph resolution phase, Gradle downloads and analyzes component metadata (GMM, POM, or Ivy XML) for declared and transitive dependencies. This information is used to construct a dependency graph, which models the relationships between different components and their variants.

The `ResolutionResult` API represents the output of the graph resolution phase, providing access to the resolved dependency graph without triggering artifact downloads. The graph itself focuses on component variants, not the artifacts (files) associated with those variants:

- ResolvedComponentResult - Represents a resolved component in the raw dependency graph.

- ResolvedVariantResult - Represents a resolved variant of a component in the raw dependency graph.

See Dependency Graph Resolution to learn more.

## 2. Artifact Resolution

Once the dependency graph is resolved, the artifact resolution phase determines which actual files (artifacts) need to be downloaded or retrieved.

An `ArtifactView` operates on top of the resolved graph, defined by the `ResolutionResult`. It allows you to query for specific artifacts based on attributes. The same attributes used during graph resolution typically guide artifact selection.

The `ArtifactView` API provides flexible ways to access these resolved artifacts:

- FileCollection - A flat list of files, which is the most commonly way to work with resolved artifacts.

- ArtifactCollection - Offers access to both the metadata and the files of resolved artifacts, allowing for more advanced artifact handling.

See Artifact Resolution to learn more.