1、执行多个任务
可以在命令行里指定多个任务依次执行,例如 gradle compile test
就会依次执行compile和test这连个任务。
不管各个任务之间的有怎样的依赖关系,每个任务都只会被执行一次。
task compile << {
println 'compiling source'
}
task compileTest(dependsOn: compile) << {
println 'compiling unit tests'
}
task test(dependsOn: [compile, compileTest]) << {
println 'running unit tests'
}
task dist(dependsOn: [compile, test]) << {
println 'building the distribution'
}
> gradle dist test
:compile
compiling source
:compileTest
compiling unit tests
:test
running unit tests
:dist
building the distribution
BUILD SUCCESSFUL
Total time: 1 secs
2、使用 -x
选项可以移除指定都任务
> gradle dist -x test
:compile
compiling source
:dist
building the distribution
BUILD SUCCESSFUL
Total time: 1 secs
3、-b
选项可以指定特定目录下的build.gradle文件,而不是当前目录下的,使用-b
选项后settings.gradle
文件不再被使用。
> gradle -q -b subdir/myproject.gradle hello
4、-p
命令可以切换执行路径到指定的项目下。
> gradle -q -p subdir hello
5、gradle projects
会列出项目结构和每个项目的描述,描述信息在每个项目的build.gradle文件中配置。
description = 'The shared API for the application'
6、gradle tasks
列出当前项目所有的task
7、gradle dependencies
列出当前项目的所有依赖
8、gradle properties
列出项目的属性