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. HTTP协议笔记整理

    有人说过,精通HTTP协议能赢过95%的前端工程师,所以我毅然的踏上这条路,哈哈哈,接下来把自己的学习笔记整理出来. 我会从比较底层的模型开始: 1.网络的五层模型 2.TCP/IP协议 3.HTTP ...

  2. 汇编语言程序环境搭建masm+debug64位 win10/7

    介绍:MASM是Microsoft Macro Assembler 的缩写,是微软公司为x86 微处理器家族开发的汇编开发环境,拥有可视化的开发界面,使开发人员不必再使用DOS环境进行汇编的开发,编译 ...

  3. LeetCode 533----Lonely Pixel II

    问题描述 Given a picture consisting of black and white pixels, and a positive integer N, find the number ...

  4. Cloudera Manager5及CDH5在线(cloudera-manager-installer.bin)安装详细文档

    问题导读:1.Cloudera Manager5如何使用cloudera-manager-installer.bin安装?2.Cloudera Manager5安装被中断该如何继续安装?还是重新安装? ...

  5. 对一些ArcGIS for JS的API的一些理解

    1.esri/map map类是每个地图控件中必须引入的类,我们可以通过Map()对地图进行许多的操作,比如修改地图的坐标系.显示级别和初始显示范围等等.   Map有一个类型为GraphicsLay ...

  6. sql server2008安装时提示重启计算机失败怎么办?

    在键盘上按下组合键[Win]+[R],调出运行窗口. 在窗口中输入“regedit”,点击确定,打开注册表管理界面. 在注册表左侧目录栏中找到如下位置:“HKEY_LOCAL_MACHINE\SYST ...

  7. /etc/vsftpd.conf详解

    #################匿名权限控制############### anonymous_enable=YES  #是否启用匿名用户no_anon_password=YES #匿名用户logi ...

  8. ajax实现跨域请求

    因为现在一直用的mvc,所以就以mvc来说说ajax跨域提交. 首先说说跨域,简单说就是不同域名访问,比如在aaa.com访问bbb.com. 就拿招聘网站来说,分为两种用户,求职者和企业,求职者端是 ...

  9. C#中Array、ArrayList和List三者的区别

    1.Array  在C#中最早出现的.在内存中是连续存储的,所以它的索引速度非常快,而且赋值与修改元素也很简单. 它的空间大小是固定的,空间不够时也不能再次申请,所以需要事前确定合适的空间大小. 2. ...

  10. Python类的继承(进阶5)

    转载请标明出处: http://www.cnblogs.com/why168888/p/6411918.html 本文出自:[Edwin博客园] Python类的继承(进阶5) 1. python中什 ...