Android studio出来也有一段时间了,很多人都推荐,包括github上的很多工程都是gradle来构建了.应该也是未来的趋势了.
现在简单的学学Gradle总归有好处的.
来看看最简单android
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
android {
compileSdkVersion 17
}
buildscript{}
Configures the build script classpath for this project.
设置脚本的运行环境
repositories{}
Returns a handler to create repositories which are used for retrieving dependencies and uploading artifacts produced by the project.
支持java 依赖库管理(maven/ivy),用于项目的依赖。这也是gradle 强力的地方。。。
dependencies{}
The dependency handler of this project. The returned dependency handler instance can be used for adding new dependencies. For accessing already declared dependencies, the configurations can be used.
依赖包的定义。支持maven/ivy,远程,本地库,也支持单文件,如果前面定义了repositories{}
maven 库,使用maven的依赖(我没接触过ivy。。)的时候只需要按照用类似于com.android.tools.build:gradle:0.4
,
gradle 就会自动的往远程库下载相应的依赖。
apply plugin:
声明构建的项目类型,这里当然是android了
android{}
设置编译android项目的参数,接下来,我们的构建android项目的所有配置都在这里完成。
参考链接:http://www.cnblogs.com/youxilua/archive/2013/05/20/3087935.html