Gradle Goodness: Display Available Tasks
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的更多相关文章
- 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 ...
- Gradle Goodness: Automatic Clean Tasks
Gradle adds the task rule clean<Taskname> to our projects when we apply the base plugin. This ...
- 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 ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- 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. ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- 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 ...
- Gradle Goodness: Excluding Tasks for Execution
In Gradle we can create dependencies between tasks. But we can also exclude certain tasks from those ...
- 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 ...
随机推荐
- 从JSON中读取数据追加到HTML中
本文来自https://www.jianshu.com/p/04127d74d88c,并非本人原创,只是作为自己学习使用的资料,如有浏览者请点击地址自行到原作者页面浏览 有时候我们需要将json数据直 ...
- UOJ169. 【UR #11】元旦老人与数列
传送门 考虑用 \(segment~tree~beats\) 那一套理论,维护区间最小值 \(mn\) 和严格次小值 \(se\) 那么可以直接 \(mlog^2n\) 维护前三个操作 考虑维护历史最 ...
- <!DOCTYPE> 标签是什么
DOCTYPE 标签,是html文档的类型声明(document type declaration,所谓声明,也就是宣称我他妈是谁),用来告诉浏览器,使用什么样的文档类型定义(Document Typ ...
- WinForm实现Rabbitmq官网6个案例-Work Queues
代码: namespace RabbitMQDemo { public partial class WorkQueues : Form { private string queueName = &qu ...
- 02_Netty实现的Echo服务器和客户端
[Echo服务端] [EchoServer] public class EchoServer { private final int port; public EchoServer(int port) ...
- #include <unistd.h> 的作用
原文:http://blog.csdn.net/ybsun2010/article/details/24832113 由字面意思,unistd.h是unix std的意思,是POSIX标准定义的uni ...
- Docker bridge探索
作者:ellen.sun链接:http://blog.daocloud.io/docker-bridge/著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 早期的二层网络中,bri ...
- winform界面开发-HTML内容编辑控件
参照及推荐博客:伍华聪 http://www.cnblogs.com/wuhuacong/archive/2009/07/07/1518346.html http://www.cnblogs.com/ ...
- Ddos 反射性防护 simple
加固NTP服务: 1.通过Iptables配置只允许信任的IP,访问本机的UDP的123端口,修改配置文件执行echo "disable monitor" >> /et ...
- 为什么懂云的IT高手能过得比你好
盼望着,盼望着,一年一度的国庆7天长假还有不到24小时就到来了.各个部门的同事都已准备好满世界旅行去了. IT 部门各位同事的心还是悬着,信息系统还要持续的运转,对外的网站不能停,假期的线上促销也不能 ...