buildsgradle中的buildscript和所有项目有什么区别? [英] What's the difference between buildscript and allprojects in build.gradle?

查看:667
本文介绍了buildsgradle中的buildscript和所有项目有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多项目gradle构建中,有人能告诉我allprojects部分和buildscript部分之间的区别究竟是什么?它们都有一个存储库依赖关系任务。是我的项目的 allprojects ?关于 buildscript

  buildscript {
repositories {
...
}
依赖关系{
...
}
}



 所有项目(子项目){
存储库{
...
}
依赖关系{
...
}
}


解决方案 buildscript 配置部分用于gradle本身(即更改为Gradle如何执行构建)。所以这部分通常会包含Android Gradle插件。


$ b allprojects 部分适用于正在构建的模块通过Gradle。

通常情况下,版本库部分对于两者来说都是相同的,因为两者通常都会从jcenter获得它们的依赖关系(或者maven central)。但依赖关系部分会有所不同。通常,allprojects的依赖关系部分是空的,因为每个模块的依赖关系都是唯一的,并且将位于每个模块中的build.gradle文件中模块。但是,如果所有模块共享相同的依赖关系,则可以在此列出。


On a multi-project gradle build, can someone tell me what exactly is the difference between the "allprojects" section and the "buildscript" one? Both have a repositories and dependencies task. Is allprojects for my project? What about buildscript?

buildscript {  
     repositories {
         ...
     }
     dependencies {
         ...
     }
}

and

allprojects(subprojects) { 
     repositories {
         ...
     }
     dependencies {
         ...
     }
}

解决方案

The "buildscript" configuration section is for gradle itself (i.e. changes to how gradle is able to perform the build). So this section will usually include the Android Gradle plugin.

The "allprojects" section is for the modules being built by Gradle.

Oftentimes the repository section is the same for both, since both will get their dependencies from jcenter usually (or maybe maven central). But the "dependencies" section will be different.

Usually the "dependencies" section for "allprojects" is empty since the dependencies for each module are unique and will be in the "build.gradle" file within each of the modules. However, if all of the modules shared the same dependencies then they could be listed here.

这篇关于buildsgradle中的buildscript和所有项目有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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