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. 虚树(Bzoj3611: [Heoi2014]大工程)

    题面 传送门 虚树 把跟询问有关的点拿出来建树,为了方便树\(DP\) 在\(LCA\)处要合并答案,那么把这些点的\(LCA\)也拿出来 做法:把点按\(dfs\)序排列,然后求出相邻两个点的\(L ...

  2. 面向对象第四章(封装、static)

    1.package: 1)作用:避免类名的冲突 2)包名可以有层次结构 3)类的全称: 包名.类名,同包中的类不能同名 4)建议:包名所有字母都小写 import: 1)同包中的类可以直接访问, 不同 ...

  3. Datatables跳转到指定页

    因为项目用到Datatables发现在分页特别多时无法跳转到指定页,自己动手增加了#Datatables 跳转到指定页#功能,实现代码如下: table = $('#user-table').data ...

  4. mysql中int、bigint、smallint 和 tinyint的区别与长度的含义【转】

    最近使用mysql数据库的时候遇到了多种数字的类型,主要有int,bigint,smallint和tinyint.其中比较迷惑的是int和smallint的差别.今天就在网上仔细找了找,找到如下内容, ...

  5. spring事务的理解

    特性 一致性:业务处理要么都成功,要么都失败,不能部分成功不分失败 原子性:业务操作是由多个动作完成,这些动作不可分割,要么都执行,要么都不执行 隔离性:事务间之间要做隔离,不要互相影响 持久性:操作 ...

  6. linux下部署redis

    基础知识: 1.Redis的数据类型: 字符串.列表(lists).集合(sets).有序集合(sorts sets).哈希表(hashs)2.Redis和memcache相比的独特之处: (1)re ...

  7. .net 的page的OnInit方法

    /// <summary> /// 重写父类的方法,父类要执行的方法已经被覆盖 /// </summary> /// <param name="e"& ...

  8. POP动画[2]

    POP动画[2] 1:定制控制器间的转场动画. 源码有点多-_-!! // // RootViewController.h // Animation // // Copyright (c) 2014年 ...

  9. 【Azure IoT DevKit】实验终于做完了

    大家好,我是MSP李桑榆 今天终于把几个Azure IoT DevKit的小实验的视频给做完了. 不敢说什么指导,只是给大家一个参考.因为Devkit不需要你写一行代码,只需要你按着步骤来,并没有什么 ...

  10. September 01st 2017 Week 35th Friday

    Each trauma, is another kind of maturity. 每一个创伤,都是另一种成熟. Sometimes the trauma may be too severe to h ...