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 group and if we look at the output of the tasks
task we can see our tasks grouped in section with the given name. In the next sample we create a new task publish
and assign it the group name Publishing.
0.
task publish(type: Copy) {
1.
from
"sources"
2.
into
"output"
3.
}
4.
5.
configure(publish) {
6.
group =
'Publishing'
7.
description =
'Publish source code to output directory'
8.
}
If we execute tasks
we get the following output:
$ gradle tasks
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Help tasks
----------
dependencies - Displays the dependencies of root project 'taskGroup'.
help - Displays a help message
projects - Displays the sub-projects of root project 'taskGroup'.
properties - Displays the properties of root project 'taskGroup'.
tasks - Displays the tasks runnable from root project 'taskGroup' (some of the displayed tasks may belong to subprojects).
Publishing tasks
----------------
publish - Publish source code to output directory
To see all tasks and more detail, run with --all.
BUILD SUCCESSFUL
Total time: 2.327 secs
Suppose we apply the Java plugin to our project. We get a lot of new tasks, which are already in groups with names like Build and Documentation. If we want to add our own custom tasks to one of those groups we only have to use the correct name for the group
property of our task. In the following build file we apply the Java plugin and use the Build group name as a group name for our task. The name is defined as a constant of the BasePlugin
.
00.
apply plugin:
'java'
01.
02.
task publish(type: Copy) {
03.
from
'sources'
04.
into
'output'
05.
}
06.
07.
configure(publish) {
08.
group = BasePlugin.BUILD_GROUP
// Or use 'build'
09.
description =
'Publish source code to output directory'
10.
}
When we run tasks
again we can see our task is in the Build section together with the tasks added by the Java plugin:
$ gradle tasks
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Build tasks
-----------
assemble - Assembles all Jar, War, Zip, and Tar archives.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles the main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
publish - Publish source code to output directory
testClasses - Assembles the test classes.
Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.
Help tasks
----------
dependencies - Displays the dependencies of root project 'taskGroup'.
help - Displays a help message
projects - Displays the sub-projects of root project 'taskGroup'.
properties - Displays the properties of root project 'taskGroup'.
tasks - Displays the tasks runnable from root project 'taskGroup' (some of the displayed tasks may belong to subprojects).
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
Rules
-----
Pattern: build<configurationname>: Assembles the artifacts of a configuration.
Pattern: upload<configurationname>: Assembles and uploads the artifacts belonging to a configuration.
Pattern: clean<taskname>: Cleans the output files of a task.
To see all tasks and more detail, run with --all.
BUILD SUCCESSFUL
Total time: 2.896 secs
Gradle Goodness: Adding Tasks to a Predefined Group的更多相关文章
- 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: 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: 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: Display Available Tasks
To see which tasks are available for our build we can run Gradle with the command-line option -t or ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
转载请注明出处:http://www.cnblogs.com/cnwutianhao/p/6709758.html Android Studio导入项目报错: org.gradle.api.inter ...
- Android studio Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to
http://blog.csdn.net/FlyRabbit_1/article/details/74536317 Error:org.gradle.api.internal.tasks.Defaul ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- 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 ...
随机推荐
- 前端(一):html标签
HTML(Hypertext Markup Language)超文本标记语言,它负责页面的结构.超文本指的是超链接,使用超链接可以从一个页面跳转到另一个页面. HTML的发展:1993年6月发布第一个 ...
- Class.forName之坑
今天遇到个问题 找不到类,最后发现 Class.forName中要完整的类名
- MySQL root 密码修改
小伙伴要在以前的服务器上装个代码版本控制的软件,要用到数据库,可是想来找去root密码还是忘了,其他已经安装的服务都是用的专用账户配置文件里要找不到root用户的密码.用以下方法将密码强制修改掉: 1 ...
- thinkphp多表联合查询
1.两个表查询 $userid=session('user.id'); $user = M('cuser'); $data = $user->field('projectno')->whe ...
- css3之背景属性之background-size
一.相关属性: background-image: url(“./img/a.jpg”); //设置元素背景图片 background-repeat: repeat/no-repeat: //设置背景 ...
- 修改phpmyadmin不能导入大文件的限制
情景:我需要导入一张1.03GB的数据表,但是phpmyadmin导入文件默认为不能超过2M.因此需要修改phpmyadmin导入文件的大小限制. 1.phpmyadmin的导入也就是php完成文件上 ...
- 排序算法Nb三人组-归并排序
归并排序只能对两个已经有序的列表进行合并排序,所以要我们自己创建出两个有序列表.最后在进行合并. def merge2list(li1, li2): li = [] i = 0 j = 0 while ...
- html高度塌陷问题解决
高度塌陷的问题: 当开启元素的BFC以后,元素将会有如下的特性 1 父元素的垂直外边距不会和子元素重叠 开启BFC的元素不会被浮动元素所覆盖 开启BFC的元素可以包含浮动的子元素 如何开启 ...
- ubuntu下root不能复制 abc用户下的软连接文件
使用root用户去复制,提示权限不足: 那么这个软连接是个什么东西??
- 针对通过 SSH 连接到 Azure Linux VM 时发生的失败、错误或被拒绝问题进行故障排除
尝试连接到 Linux 虚拟机 (VM) 时,有多种原因可能会导致安全外壳 (SSH) 错误.SSH 连接失败或被拒绝. 本文帮助用户找出原因并更正问题. 可以使用 Azure 门户.Azure CL ...