项目全局build.gradle

一个完整的项目全局build.gradle文件,如下所示。

  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2.  
  3. buildscript {
  4. repositories {
  5. jcenter()
  6. }
  7. dependencies {
  8. classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
  9.  
  10. // NOTE: Do not place your application dependencies here; they belong
  11. // in the individual module build.gradle files
  12. }
  13. }
  14.  
  15. allprojects {
  16. repositories {
  17. jcenter()
  18. }
  19. }
  20.  
  21. task clean(type: Delete) {
  22. delete rootProject.buildDir
  23. }

实际上,项目全局的build.gradle文件中最重要的就是buildscript的部分代码。在buildscript中,Gradle指定了使用jcenter代码仓库,同时声明了依赖的Android Gradle插件的版本。

在allprojects领域中,开发者可以为项目整体配置一些属性。