To see which tasks are available for our build we can run Gradle with the command-line option -t or --tasks. Gradle outputs the available tasks from our build script. By default only the tasks which are dependencies on other tasks are shown. To see all tasks we must add the command-line option --all.

00.3.times { counter ->
01.task "lib$counter" {
02.description = "Build lib$counter"
03.if (counter > 0) {
04.dependsOn = ["lib${counter - 1}"]
05.}
06.}
07.}
08. 
09.task compile {
10.dependsOn {
11.project.tasks.findAll {
12.it.name.startsWith('lib')
13.}
14.}
15.description = "Compile sources"
16.}
$ gradle -q -t
 
------------------------------------------------------------
Root Project
------------------------------------------------------------
 
Tasks
-----
:compile - Compile sources
$ gradle -q --tasks -all
 
------------------------------------------------------------
Root Project
------------------------------------------------------------
 
Tasks
-----
:compile - Compile sources
:lib0 - Build lib0
:lib1 - Build lib1
:lib2 - Build lib2

But if we add our tasks to a group, we get even more verbose output. Gradle will group the tasks together and without the --all option we get to see all tasks belonging to the group, even those that are dependency tasks. And with the --all option we see for each task on which tasks it depends on. So by setting the group property on the task we get much better output when we ask Gradle about the available tasks.

00.3.times { counter ->
01.task "lib$counter" {
02.description = "Build lib$counter"
03.if (counter > 0) {
04.dependsOn = ["lib${counter - 1}"]
05.}
06.}
07.}
08. 
09.task compile {
10.dependsOn {
11.project.tasks.findAll {
12.it.name.startsWith('lib')
13.}
14.}
15.description = "Compile sources"
16.}
17. 
18.tasks*.group = 'Compile'
$ gradle -q -t
 
------------------------------------------------------------
Root Project
------------------------------------------------------------
 
Compile tasks
-------------
:compile - Compile sources
:lib0 - Build lib0
:lib1 - Build lib1
:lib2 - Build lib2
$ gradle -q --tasks -all
 
------------------------------------------------------------
Root Project
------------------------------------------------------------
 
Compile tasks
-------------
:compile - Compile sources [:lib0, :lib1, :lib2]
:lib0 - Build lib0
:lib1 - Build lib1 [:lib0]
:lib2 - Build lib2 [:lib1]

Gradle Goodness: Display Available Tasks的更多相关文章

  1. Gradle Goodness: Group Similar Tasks

    In Gradle we can assign a task to a group. Gradle uses the group for example in the output of $ grad ...

  2. Gradle Goodness: Automatic Clean Tasks

    Gradle adds the task rule clean<Taskname> to our projects when we apply the base plugin. This ...

  3. Gradle Goodness: Continue Build Even with Failed Tasks

    If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have f ...

  4. Gradle Goodness: Task Output Annotations Create Directory Automatically

    Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...

  5. Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects

    Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects Gradle is very flexible. ...

  6. Gradle Goodness: Copy Files with Filtering

    Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...

  7. Gradle Goodness: Changing Name of Default Build File

    Gradle uses the name build.gradle as the default name for a build file. If we write our build code i ...

  8. Gradle Goodness: Excluding Tasks for Execution

    In Gradle we can create dependencies between tasks. But we can also exclude certain tasks from those ...

  9. Gradle Goodness: Adding Tasks to a Predefined Group

    In Gradle we can group related tasks using the group property of a task. We provide the name of our ...

随机推荐

  1. Get a “step-by-step” evaluation in Mathematica

    Is it possible in Mathematica to get a step-by-step evaluation of some functions; that's to say, out ...

  2. Activiti实现会签功能

    一个任务需要多个角色进行审批或者表决,根据这些审批结果来决定流程的走向.实现以上任务,activiti已经提供了支持,可以使用BPMN规范的多实例活动来实现. 1.Activiti多实例: 多实例节点 ...

  3. 理解ASP.NET 5运行时命令:DNVM, DNX, 和DNU

    ASP.NET 5 引入了一个新型的运行时,让我们可以现场交付模式组合式构建应用程序,而不依赖于宿主机上的.NET框架.这种新模式为我们提供了命令行工具(DNVM.DNX.DNU)用于管理我们的.ne ...

  4. spring mvc拦截器HandlerInterceptor

    本文主要介绍springmvc中的拦截器,包括拦截器定义和的配置,然后演示了一个链式拦截的测试示例,最后通过一个登录认证的例子展示了拦截器的应用 拦截定义 定义拦截器,实现HandlerInterce ...

  5. 听说是个集成版的监控,不知道你听过没? C+C+N

    Cnyunwei-Cacti+Nagios 下载地址1:http://pan.baidu.com/s/1mgn1rsc 下载地址2:http://sourceforge.net/projects/cn ...

  6. BigDecimal setScale()设置无效 scale()取得的值不是setScale()设置的值

    最近查看rebate数据时,发现一个bug,主要现象是,当扣款支付宝的账号款项时,返回的是数字的金额为元,而数据库把金额存储为分,这中间要做元与分的转化,这个转化规则很简单,就是*100的,所以一开始 ...

  7. C#的抽象类和接口的区别,在什么时候使用才合适?

    理解抽象类  abstract class和interface在c#语言中都是用来进行抽象类(本文 中的抽象类并非从abstract class翻译而来,它表示的是一个抽象体,而abstract cl ...

  8. [翻译] CHAnimation

    CHAnimation https://github.com/cyndibaby905/CHAnimation How it looks CHAnimation is a project used t ...

  9. HTML简单框架网页制作 吴昊

  10. 每年支付 m 次的年金

    每年支付 m 次的年金 n 表示年数.m 表示每年的付款次数.i 表示年实际利率. 一.期末付年金(annuity-immediate payable mthly): 每年支付m次, 每次的付款为1/ ...