How To Add a Repository

The SDK 6 installation process asks to create a Gradle Init Script file to declare modules and plugins repositories. You may need to use additional repositories or replace the default ones, for example to fetch a module only available in your company’s repository. This page presents the different options to do that.

If you need more details on this topic, refer to the official Gradle documentation on repository declaration.

Note

In addition to the solutions described in the following sections, it is also possible to directly update the Gradle Init Script to add, replace or delete a repository. The version of this script provided in the installation process is a recommended version to be applied to quickly setup an environment. However, it can be modified to adapt it to your need, especially for the list of repositories. The module repositories are defined in the block beforeSettings > dependencyResolutionManagement > repositories and the plugin repositories are defined in the block beforeSettings > pluginManagement > repositories. They are applied to all the Gradle builds executed on the machine.

How To Add a Module Repository …

… in addition to the Init Script Repositories

If the Module Repositories declared in the Gradle Init Script are declared in a dependencyResolutionManagement block, you can declare additional repositories for your project in the settings.gradle.kts file with:

dependencyResolutionManagement {
  repositories {
    maven {
      name = "myModuleRepository"
      url = uri("https://my.company/my-module-repository")
    }
  }
}

With this configuration, Gradle starts by fetching the modules from the repositories declared in the Init Script, then from the ones declared in the settings.gradle.kts project file.

… to replace the Init Script Repositories

If you want to declare the list of repositories directly in your project, no matter what is defined in the Gradle Init Script, you must declare them directly in the build.gradle.kts file of your project:

repositories {
  maven {
    name = "myModuleRepository"
    url = uri("https://my.company/my-module-repository")
  }
}

If you want to apply this configuration to all the subprojects of a multi-project, the repositories must be declared in a build.gradle.kts file located in the root folder, inside a subprojects block (or allprojects depending on your needs):

subprojects {
  repositories {
    maven {
      name = "myModuleRepository"
      url = uri("https://my.company/my-module-repository")
    }
  }
}

How To Add a Plugin Repository

To add a plugin repository, add a pluginManagement > repositories block in the settings.gradle.kts file of your project:

pluginManagement {
  repositories {
    maven {
      name = "myPluginRepository"
      url = uri("https://my.company/my-plugin-repository")
    }
  }
}

The repositories defined here are fetched after the ones defines in the Gradle Init Script.

Note

To be noted that if no plugin repository is defined (in either the Init Script or the project), Gradle uses the Gradle Plugin Portal.