Gradle User Guide(3)——使用命令行

来源:互联网 发布:linux ping 间隔时间 编辑:程序博客网 时间:2024/06/16 00:53

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:compilecompiling source:compileTestcompiling unit tests:testrunning unit tests:distbuilding the distributionBUILD SUCCESSFULTotal time: 1 secs

2、使用 -x 选项可以移除指定都任务

> gradle dist -x test:compilecompiling source:distbuilding the distributionBUILD SUCCESSFULTotal 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 列出项目的属性

0 0
原创粉丝点击