Search code examples
buildrepositorygradle

Gradle buildscript dependencies


What is the difference between declaring repositories in the buildscript section of the gradle build or in the root level of the build.

buildscript {
    repositories {
        mavenCentral();
    }
}

versus

repositories {
    mavenCentral();
}

Solution

  • The repositories in the buildscript block are used to fetch the dependencies of your buildscript dependencies. These are the dependencies that are put on the classpath of your build and that you can refer to from your build file. For instance extra plugins that exist on the internet.

    The repositories on the root level are used to fetch the dependencies that your project depends on. So all the dependencies you need to compile your project.