【转】gradle与gradle wrapper关系,以及版本关系

关于gradle、gradle plugin、gradle和gradlew的具体说明,还请参见以下链接:
http://hucaihua.cn/2016/09/27/Gradle_upgrade/

转自:http://blog.csdn.net/klx502/article/details/50762059

gradle-wrapper.properties中的设置

1
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

build.gradle中的设置

1
2
3
4
5
6
7
8
9
10
11
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

上述两个与gradle相关的设置,有何关系和区别?

问:
在上述两个设置文件中,与gradle相关但是用到了不同的版本设置。那么他们的关系到底是什么样的?gradle wrapper作用是什么?

答:
gradle wrapper task利用gradle-wrapper.properties来下载指定的gradle。

build.gradle中classpath ‘com.android.tools.build:gradle:1.5.0’表示要使用这个android plugin的库,而这个android plugin是对gradle库的扩展。

前者是gradle的版本,当时正式版最新的是2.9。实际上是到这里下载https://services.gradle.org/distributions;
后者是android plugin的版本,当时正式版本最新是1.5.0。实际上是到这里来下载https://jcenter.bintray.com/com/android/tools/build/gradle/1.5.0/。

另外的配置问题参考

可参见http://blog.csdn.net/rodulf/article/details/50679928。