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 ...
随机推荐
- 网站SEO优化
网站的优化应该迎合搜索引擎,这样才能得到事半功倍的效果! 一.站内优化 1.做好HTML头标签 标题(title):标题是网页优化中相当有分量,一般网页title主要包含一些关键词.网站名称等.关键词 ...
- 深入浅出ConcurrentHashMap1.8
转载:https://www.jianshu.com/p/c0642afe03e0 好文 关于文章中的疑问:为什么要构造一个反序链表,放在nextTable的i+n的位置上呢,在<深入分析Con ...
- gulpfile配置
/** * 只包含合并压缩混淆,监听服务 */// 引入gulp模块var gulp = require('gulp'); // 引入其他模块var less = require('gulp-less ...
- 孙鑫VC++视频教程(1-20课全)
孙鑫VC++视频教程(1-20课全)PPT讲义和源代码 http://down.51cto.com/data/467760 孙鑫VC++从入门到精通开发详解视频教程[20讲] http://down. ...
- 目前比较全的CSS重设(reset)方法总结(转)
原文地址 在当今网页设计/开发实践中,使用CSS来为语义化的(X)HTML标记添加样式风格是重要的关键.在设计师们的梦想中都存在着这样的一个完美世界:所有的浏览器都能够理解和适用多有CSS规则,并且呈 ...
- 多线程 读写锁SRWLock
在<秒杀多线程第十一篇读者写者问题>文章中我们使用事件和一个记录读者个数的变量来解决读者写者问题.问题虽然得到了解决,但代码有点复杂.本篇将介绍一种新方法——读写锁SRWLock来解决这一 ...
- Php 性能参数优化 及 Iptables 防火墙限制用户访问平率
Php-Fpm.Conf 文件配置优化 [global] pid = run/php-fpm.pid process_control_timeout=5 [www] listen.allowed_cl ...
- 贴现率d与利率i
一.复利中的实际利率 it=(1+i)t -(1+i)t-1 / (1+i)t-1=i i 为常数, 而单利的实际利率递减 二.贴现 时间t的1元在时间零点的价值为贴现函数 记为 a-1(t) ...
- [EffectiveC++]item39:明智而审慎地使用private
187页 private继承意味implementedin-terms-of(根据某物实现出).如果你让class D以private形式继承class B,你的用意为了采用class B内已经备妥的 ...
- LDA相关论文汇总
转:http://blog.csdn.net/pirage/article/details/9467547 LDA理论 David M. Blei, Andrew Y. Ng, and Michael ...