# Centralizing Repository Declarations

version 9.8.0-20260813012148+0000

Instead of declaring repositories in every subproject of your build or via an `allprojects` block, Gradle provides a way to declare them centrally for all projects.

| Central declaration of repositories is an incubating feature.

You can declare repositories that will be used by convention in every subproject in the `settings.gradle(.kts)` file:

settings.gradle.kts

    dependencyResolutionManagement {
        repositories {
            mavenCentral()
        }
    }

settings.gradle

    dependencyResolutionManagement {
        repositories {
            mavenCentral()
        }
    }

The `dependencyResolutionManagement` repositories block accepts the same notations as in a project, including Maven or Ivy repositories, with or without credentials.

## Repositories mode

By default, repositories declared in a project’s `build.gradle(.kts)` file will override those declared in `settings.gradle(.kts)`. However, you can control this behavior using the `repositoriesMode` setting:

settings.gradle.kts

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.PREFER_PROJECT
    }

settings.gradle

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.PREFER_PROJECT
    }

## Available modes

There are three modes for dependency resolution management:

Mode | Description | Default? | Use-Case
--- | --- | --- | ---
`PREFER_PROJECT` | Repositories declared in a project override those declared in `settings.gradle(.kts)`. | Yes | Useful when teams need to use different repositories specific to their subprojects.
`PREFER_SETTINGS` | Repositories declared in `settings.gradle(.kts)` override those declared in a project. | No | Useful for enforcing the use of approved repositories across large teams.
`FAIL_ON_PROJECT_REPOS` | Declaring a repository in a project triggers a build error. | No | Strictly enforces the use of repositories declared in `settings.gradle(.kts)`.

You can change the behavior to prefer the repositories in `settings.gradle(.kts)`:

settings.gradle.kts

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.PREFER_SETTINGS
    }

settings.gradle

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.PREFER_SETTINGS
    }

Gradle will warn you if a project or plugin declares a repository when using this mode.

To enforce that only repositories declared in `settings.gradle(.kts)` are used, you can configure Gradle to fail the build when a project plugin is declared:

settings.gradle.kts

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
    }

settings.gradle

    dependencyResolutionManagement {
        repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
    }