美文网首页
What's the difference between bu

What's the difference between bu

作者: 好学人 | 来源:发表于2019-07-08 21:51 被阅读0次

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.

参考资料:https://stackoverflow.com/questions/30158971/whats-the-difference-between-buildscript-and-allprojects-in-build-gradle

相关文章

网友评论

      本文标题:What's the difference between bu

      本文链接:https://www.haomeiwen.com/subject/pcdzhctx.html