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. SQLServer数据库系统概念

    数据模型是一种抽象模型,现实世界中的客观事物是彼此相互联系的 (1)数据模型是一组集成的概念,用户描述和操作组织内的数据,数据间的联系以及对数据的约束,它包含了数据结构,数据操作和完整性约束 (2)概 ...

  2. jQuery轮播图(一)轮播实现并封装

    利用面向对象自己动手写了一个封装好的jquery轮播组件,可满足一般需求,不仅使用简单且复用性高. demo:点此预览 代码地址:https://github.com/zsqosos/componen ...

  3. vue-cli构建项目 npm run build后应该怎么运行在本地查看效果

    问题: 就是 bulid 打包后,想本地看看效果,本地看不了.... 网上看到一个....   具体更多在: http://www.dabaipm.cn/static/frontend/346.htm ...

  4. ssm 注解@ResponseBody 返回json 乱码问题

    方法一:在@RequestMapping上加入 produces方法 @RequestMapping(value = "/upload.do",method = RequestMe ...

  5. Install MySQL on Mac

    1. 可参考此文章:http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html 2. 目前MySQL(我用的mysql 5 ...

  6. post字符 特殊字符处理【转】

    今天和同事调试接口,由于产品设计的问题,传递的参数没有做任何的限制.同事就在传参数的时候加了些特殊字符到后台,但是后台打印的日志是 null... 然后上网搜了下解决办法:转 https://www. ...

  7. SSH笔记一

    加入JAR包(包括c3p0和sql的,重复包删低版本的) 加入Spring 1)  配置web.xml文件 ------删内容留web-app--------ctrl+shift+f--------c ...

  8. Linux常用命令(三)————创建+删除+设置权限

    1. mkdir mkdir [选项] DirName 命令中的[选项]: -m    用于对新建目录设置存取权限,也可以用 chmod 命令进行设置. -p     需要时创建上层文件夹(或目录), ...

  9. SQLServer2008或SQLServer2008 R2没有智能提示解决方法

    如果没有智能提示,需要安装SqlcompletefreeSQL Server智能提示

  10. 中文乱码(Python、WEB、ajax)

    http://my.oschina.net/leejun2005/blog/74430 #查看errorb是unicode,还是stringprint isinstance(errorb,unicod ...