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 ...
随机推荐
- css 样式加载次序
一般而言,所有的样式会根据下面的规则层叠于一个新的虚拟样式表中,其中数字 4 拥有最高的优先权(本人理解为:先加载1的样式,然后用2的样式覆盖1中的样式,3.4同理) 浏览器缺省设置(浏览器默认的样式 ...
- bootstrap fileinput +springmvc图片上传-krajee
引入的文件 <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-fileinput/4.4.9/css/filei ...
- Berlekamp-Massey算法
\(BM\) 算法 用处 它可以用来求常系数线性递推的系数,并且可以求出最短的 求出来有什么用呢? 你可以闷声Cayley-Hamilton定理优化递推矩阵快速幂 算法简介 首先设一个数列 \(f\) ...
- Maven学习总结(六):pom.xml文件的说明
什么是POM? POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示,名称叫做pom.xml.作用类似ant的build.xml文件,功能 ...
- 前端面试题1(html)
HTML * Doctype作用?严格模式与混杂模式如何区分?它们有何意义? 1.<!DOCTYPE> 声明位于文档中的最前面的位置,处于 <html> 标签之前.此标 ...
- Mongodb的入门(7)window安装mongodb4
Mongodb4: MongoDB CTO Eliot Horowitz 刚刚于2月16日凌晨在MongoDB西雅图大会上宣布,MongoDB将在4.0版本中正式推出多文档ACID事务支持 . “Mo ...
- 基于PMBOK的项目管理知识体系
- ubuntu搭建LAMP全教程及简单使用
一:安装: 参考:http://jingyan.baidu.com/article/a681b0de36ad683b18434691.html 本经验向你展示如何在ubuntu14.04 环境下搭建a ...
- Angular5中提取公共组件之checkbox list
因为工作原因,需要使用到checkbox list多选项功能. 一直在尝试在checkbox组件中添加NgModel的属性,但是只能在单个checkbox复选框上使用,checkbox list就没办 ...
- Excel VBA Range对象基本操作应用示例
[示例01] 赋值给某单元格[示例01-01] Sub test1()Worksheets("Sheet1").Range("A5").Value = 22Ms ...