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 ...
随机推荐
- Maven 配置tomcat和findbug插件(在eclipse建立的项目中)
tomcat插件 a) tomcat的maven插件可以在tomcat的官网上寻找,这就是tomcat插件的plugin b) 将tomcat的plugin配置到项目的po ...
- CSS3之盒模型
1. 什么是盒模型? css中的每个元素都是一个盒模型, 包括html body元素, 浏览器解析css的时候也会把每个元素看成一个盒子来解析. 盒模型具备的属性(存在的特点)有: content ( ...
- SQL Server UDF to pad a string
http://www.mssqltips.com/sqlservertip/1738/sql-server-udf-to-pad-a-string/ declare @l varchar(50) se ...
- Eclipse常用操作
一 Eclipse常用快捷键 ctrl+Q:跳到最后一次编辑处. ctrl+F:在当前文件中查找并替换. ctrl+T:查看类的继承关系. alt+左箭头:返回到光标的上一个位置. alt+右箭头:前 ...
- vue中数组删除,页面没重新渲染
创建一个组件时,数据类型是数组,在删除这个数组中的数据时,数组中的数据是对的,但页面渲染的数据却不对. 举例:(不一定复现) <ul> <li v-for="(item, ...
- 解决Non-resolvable parent POM: Could not find artifact 出现的问题
在编译spring boot 多模块项目的时候,往往出现 Non-resolvable parent POM: Could not find artifact 后面跟一串其它信息,网上大部分解决方案是 ...
- git 命令备忘
git 常用命令备忘 仅作为日常使用备忘,并非常用命名整理 删除源端分支 git push orgin --delete branch_a a分支某次提交应用到b分支 切换到branch_b 分支: ...
- Oracle案例01——ORA-09925: Unable to create audit trail file
2018年春节后第一天上班就遇到一个审计日志无法写入的问题,具体解决思路如下. 一.错误日志 数据库错误日志内容: Fri Feb 23 11:16:30 2018OS Audit file coul ...
- TCP_Wrappers 简介
TCP_Wrappers 简介 TCP_Wrappers是一个工作在第四层(传输层)的的安全工具,对有状态连接的特定服务进行安全检测并实现访问控制,凡是包含有libwrap.so库文件的的程序 ...
- cocos2d-x 3.1 编译脚本android-build.py
写在前面: 前段时间下载了cocos2d-x 3.1,按照官网的教程,配置环境,编译打包,走了一遍,感觉不错,顺便发现其中用了很多python的脚本文件,比如今天要说的android-build.py ...