在Android Studio的Project的build.gradle中,

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.novoda:bintray-release:0.4.0' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
} allprojects {
repositories {
jcenter()
maven {url 'https://dl.bintray.com/calvinning/maven'}
}
}

那么buildscript中的repositories和allprojects的repositories的作用和区别是什么呢?
答:
1、 buildscript里是gradle脚本执行所需依赖,分别是对应的maven库和插件
2、 allprojects里是项目本身需要的依赖,比如我现在要依赖我自己maven库的toastutils库,那么我应该将maven {url 'https://dl.bintray.com/calvinning/maven'}写在这里,而不是buildscript中,不然找不到。

  • 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.

作者:CalvinNing
链接:https://www.jianshu.com/p/ee57e4de78a3
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

buildscript和allprojects的作用和区别是什么?的更多相关文章

  1. call、apply的作用和区别是什么?

    call().apply()的区别: 相同点: 1.call()和apply()都可以用来间接调用函数,都可以显式调用所需的this.即,任何函数可以作为任何对象的方法来调用. 2.两个方法都可以指定 ...

  2. Gradle 知识点

    mac 系统中,下载的 Gradle 压缩包解压后存储的文件夹:/Users//.gradle/wrapper/dists 当Gradle运行时,会根据settings.gradle的配置情况,构建一 ...

  3. Gradle入门学习---认识buildeTypes和dependencies

    Gradle是Android Studio默认的构建工具,如果是基本的APP开发,不会涉及到Gradle太多内容,毕竟它的诞生就不是专为Android服务的. 日常开发需要涉及到使用Gradle的场景 ...

  4. MyBatis Generator 详解

    MyBatis Generator中文文档 MyBatis Generator中文文档地址:http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看中 ...

  5. Struts2配置文件详解

    解决在断网环境下,配置文件无提示的问题我们可以看到Struts.xml在断网的情况下,前面有一个叹号,这时,我们按alt+/ 没有提示,这是因为” http://struts.apache.org/d ...

  6. MyBatis Generator 详解 【转来纯为备忘】

    版权声明:版权归博主所有,转载请带上本文链接!联系方式:abel533@gmail.com   目录(?)[+] MyBatis Generator中文文档 运行MyBatis Generator X ...

  7. mybatis Generator配置文件详解

    这里按照配置的顺序对配置逐个讲解,更细的内容可以配合中文文档参照. 1. 配置文件头 <?xml version="1.0" encoding="UTF-8&quo ...

  8. JVM初探 -JVM内存模型

    JVM初探 -JVM内存模型 标签 : JVM JVM是每个Java开发每天都会接触到的东西, 其相关知识也应该是每个人都要深入了解的. 但接触了很多人发现: 或了解片面或知识体系陈旧. 因此最近抽时 ...

  9. struts.properties配置详解

    Struts 2框架有两个核心配置文件,其中struts.xml文件主要负责管理应用中的Action映射,以及该Action包含的Result定义等.除此之外,Struts 2框架还包含     st ...

随机推荐

  1. C8051F环境搭建

    https://www.silabs.com/ USB调试器 U-EC6: 支持JTAG模式.C2模式 JTAG接口定义: 适用型号C8051F00x C8051F01x C8051F02x C805 ...

  2. 【SpringBoot】整合日志框架

    一.日志框架概述 1.1 日志框架的产生 1.2 市面上的日志框架 二.SLF4j 使用与整合 2.1 如何在系统中使用SLF4j 2.2 如何整合日志框架 2.3 SpringBoot中的日志关系 ...

  3. shell脚本编写之Hello World

    Linux下编写第一个Shell脚本 //创建一个.sh文件 vi demo1.sh //按i进入编辑模式 echo "Hello World !" //按esc→shift+:→ ...

  4. 理解 chroot

    什么是 chroot chroot,即 change root directory (更改 root 目录).在 linux 系统中,系统默认的目录结构都是以 `/`,即是以根 (root) 开始的. ...

  5. Django项目实战—用户头像上传

    1 将文件保存到服务器本地 upload.html <!DOCTYPE html> <html lang="en"> <head> <me ...

  6. CAFFE(四):Ubuntu 下安装jupyter notebook

    第一步.安装 pycaffe notebook 接口环境 在上一步成功安装 caffe 之后,就可以通过 caffe 去做训练数据集或者预测各种相关的事了,只不过需要在命令行下通过 caffe 命令进 ...

  7. Linux环境下交叉编译器安装及运行

    描述: 由于 使用第三方编译器是提示No such file or directory 原因:编译器为32位版本,而系统是64位的 解决方法:安装32位版本编译支持库 sudo apt-get ins ...

  8. Winform 多项目共用AssemblyInfo解决方案

    Winform 多项目共用AssemblyInfo解决方案: 操作步骤如下: 第一步:复制任何项目中的AssemblyInfo.cs文件至指定目录 第二步:删除所有项目的AssemblyInfo.cs ...

  9. vim编辑命令

    vi命令 命令模式: yy:复制 光标所在的这一行 4yy:复制 光标所在行开始向下的4行 p: 粘贴 dd:剪切 光标所在的这一行 2dd:剪切 光标所在行 向下 2行 D:从当前的光标开始剪切,一 ...

  10. 如何正确清理C盘?

    Windows电脑操作系统一般是安装在磁盘驱动器的C盘中,一旦运行,便会产生许多垃圾文件,C盘空间在一定程度上都会越来越小.伴随着电脑工作的时间越久,C盘常常会提示显示其内存已不足.那么C盘容量不足对 ...