Can I Define The buildscript repositories In The R

2019-08-31 04:46发布

问题:

I have code similar to the following in each of my sub-modules but with different plugins

buildscript {
    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

Can the repositories be set in the root project so I don't repeat it?

I already have the main repositories section set in the root like this but this question is for the plugins and the buildscript section.

allprojects {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
    }
} 

回答1:

The  buildscript block can't be put into a separate file and then imported, it's a special one.

What you can do on the other hand is to put your buildscript block into the build.gradle file of the root project and then all other build files from subprojects will inherit this block.



标签: gradle