我可以在Root项目中为所有模块定义buildscript存储库吗? [英] Can I Define The buildscript repositories In The Root Project For All Modules

查看:49
本文介绍了我可以在Root项目中为所有模块定义buildscript存储库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个子模块中都有与以下代码类似的代码,但是具有不同的插件

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?

我已经在根目录中设置了主要的存储库部分,但是这个问题是针对插件和 buildscript 部分的.

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' }
    }
} 

推荐答案

buildscript 块不能放入单独的文件中然后再导入,这是一个特殊的文件.

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

另一方面,您可以做的是将您的 buildscript 块放入根项目的 build.gradle 文件中,然后子项目中的所有其他构建文件将继承此块.

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.

这篇关于我可以在Root项目中为所有模块定义buildscript存储库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆