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

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 列出项目的属性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值