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 ...
随机推荐
- Android源码下编译APK步骤
1.进入android源码目录下的build下执行:source envsetup.sh 后继续在该路径下执行lunch. 2.编写完成工程 3.编写Android.mk文件,放入工程目录下 ...
- 第5章 css与背景相关的样式background
background-origin 设置元素背景图片的原始起始位置. 语法: background-origin : border-box | padding-box | content-box; 参 ...
- H5,API的pushState(),replaceState()和popstate()用法
pushState和replaceState是H5的API中新添加的两个方法.通过window.history方法来对浏览器历史记录的读写. pushState和replaceState 在 HTML ...
- 廖雪峰JavaScript练习题
练习:不要使用JavaScript内置的parseInt()函 数,利用map和reduce操作实现一个string2int()函数: <!DOCTYPE html> <html&g ...
- js 两个小括号 ()() 的用法
实现一个函数fn, 使fn(1)(2)的结果为两个参数的和,刚开始没反应过来,其实细细一想第二个括号就是函数再调用的问题,废话不多说,代码奉上: var fn = function(n) { func ...
- Web前端面试指导(十五):CSS样式-display有哪些作用?
题目点评 其实就是要你说清楚该属性有哪些值,每个值都有什么作用,这个题目可以答得很简单,但要答全也并非是一件容易的事情. 元素默认的display值的情况如下(这个一般很少人注意这一点) block( ...
- 基础架构之GitLab
Git几乎是软件开发人员的必备工具了,关于代码管理,公司都一般都会搭建自己的仓库,关于GitLab的详细介绍参见官方网站详见 https://about.gitlab.com,这篇文章主要介绍安装及使 ...
- atom 常用配置
基本配置 setting 位于 File -> setting 显示HTML标签闭合的竖线 Setting -> Editor Setting -> 勾选 Show Indent G ...
- angularJS articles and resources
http://antjanus.com/blog/web-development-tutorials/front-end-development/comprehensive-beginner-guid ...
- js前台检测上传图片大小的总结
最近一直在做上传图片的前端检测,不通过后台就完成这个动作.但实际是,实际效果差强人意. html5的fileApi出来后,对文件的处理才变得方便了些,对它的简单介绍可以看我的前面的博客.现在支持的浏览 ...