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 messageprojects - 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 directoryTo see all tasks and more detail, run with --all.BUILD SUCCESSFULTotal time: 2.327 secsSuppose 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 directorytestClasses - 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 messageprojects - 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 SUCCESSFULTotal time: 2.896 secsGradle 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 ...
随机推荐
- 如何去除vue项目中的 # — vue路由的History模式
前言 在创建的 router 对象中,如果不配置 mode,就会使用默认的 hash 模式,该模式下会将路径格式化为 #! 开头. 添加 mode: 'history' 之后将使用 HTML5 his ...
- 微信小程序,动态改变样式
小程序目前没有修改样式api,但是可以利用数据绑定实现动态改变样式,可以用view标签模拟page然后改变view标签的样式,以下案例演示了如果改变page背景颜色: <view class=& ...
- CSS 3动画
CSS 3在原来的基础上新增了变形和动画相关的属性,通过这些属性可以实现以前需要大段JavaScript才能实现的功能.css 3的变形功能可以对HTML元素执行位移.旋转.缩放.倾斜4种几何变换,借 ...
- endwith与startwith字符串方法匹配重写
endwith与startwith字符串方法匹配重写 在js读取文件信息并判断文件的格式类型时出现问题,并找到解决方案,写下来与大家分享,共勉. ---DanlV 描述 本人在上传MP3格式文件时,需 ...
- 2-1 Sass的控制命令
@if @if 指令是一个 SassScript,它可以根据条件来处理样式块,如果条件为 true 返回一个样式块,反之 false 返回另一个样式块.在 Sass 中除了 @if 之,还可以配合 @ ...
- ASPF(Application Specific Packet Filter)
ASPF ASPF(Application Specific Packet Filter)是针对应用层的包过滤,其原理是检测通过设备的报文的应用层协议信息,记录临时协商的数据连接,使得某些在安全策略中 ...
- 【转】R树空间索引
R树在数据库等领域做出的功绩是非常显著的.它很好的解决了在高维空间搜索等问题.举个R树在现实领域中能够解决的例子吧:查找20英里以内所有的餐厅.如果没有R树你会怎么解决?一般情况下我们会把餐厅的坐标( ...
- .NET开源工作流RoadFlow-流程运行-工作委托
如果某一个人某一段时间不在单位,则可以将自己的工作委托给他人代为处理. 在 流程处理-->工作委托 中可以管理自己的委托,管理员也可以在 流程管理-->工作委托 中管理所有人的委托: 委托 ...
- 项目经验:GIS<MapWinGIS>建模第六天
针对管网的暴管发生情况的,关阀分析,能够更快,更及时给施工作人员找到最近需要关停的阀门点,及受影响的管网段,如在这个区域内,还能找到受影响需要停水的用户
- Day01——Python简介
一.Python简介 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC ...