Gradle Goodness: Rename Ant Task Names When Importing Ant Build File
Migrating from Ant to Gradle is very easy with the importBuild method from AntBuilder. We only have to add this single line and reference our existing Ant build XML file and all Ant tasks can now be executed as Gradle tasks. We can automatically rename the Ant tasks if we want to avoid task name collisions with Gradle task names. We use a closure argument with the importBuild method and return the new task names. The existing Ant task name is the first argument of the closure.
Let's first create a simple Ant build.xml file:
00.<project>01. 02.<target name="showMessage"03.description="Show simple message">04. 05.<echo message="Running Ant task 'showMessage'"/>06. 07.</target>08. 09.<target name="showAnotherMessage"10.depends="showMessage"11.description="Show another simple message">12. 13.<echo message="Running Ant task 'showAnotherMessage'"/>14. 15.</target>16. 17.</project>The build file contains two targets: showMessage and showAnotherMessage with a task dependency. We have the next example Gradle build file to use these Ant tasks and prefix the original Ant task names with ant-:
00.// Import Ant build and 01.// prefix all task names with02.// 'ant-'.03.ant.importBuild('build.xml') { antTaskName ->04."ant-${antTaskName}".toString()05.}06. 07.// Set group property for all 08.// Ant tasks.09.tasks.matching { task ->10.task.name.startsWith('ant-')11.}*.group = 'Ant'We can run the tasks task to see if the Ant tasks are imported and renamed:
$ gradle tasks --all...Ant tasks---------ant-showAnotherMessage - Show another simple message [ant-showMessage]ant-showMessage - Show simple message...$We can execute the ant-showAnotherMessage task and we get the following output:
00.$ gradle ant-showAnotherMessage01.:ant-showMessage02.[ant:echo] Running Ant task 'showMessage'03.:ant-showAnotherMessage04.[ant:echo] Running Ant task 'showAnotherMessage'05. 06.BUILD SUCCESSFUL07. 08.Total time: 3.953 secs09.$Written with Gradle 2.2.1
Gradle Goodness: Rename Ant Task Names When Importing Ant Build File的更多相关文章
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- Gradle Goodness: Check Task Dependencies With a Dry Run
We can run a Gradle build without any of the task actions being executed. This is a so-called dry ru ...
- Gradle Goodness: Working with Live Task Collection
Gradle support the definition of so called live collections. These collections are mostly created ba ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- Gradle Goodness: Renaming Files while Copying
With the Gradle copy task we can define renaming rules for the files that are copied. We use the ren ...
- 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 ...
- 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学习之创建Task的方法
请通过下面方式下载本系列文章的Github演示样例代码: git clone https://github.com/davenkin/gradle-learning.git Gradle的Pr ...
- Gradle 使用教程之 Task 详解
最近打算学习下 gradle 在 Android 中的使用,结果百度出来的文章都是介绍性文章,没啥干货.后来找到 gradle 官网教程,自己对着撸. Gradle 概述: Gradle 是一个基于 ...
随机推荐
- 为什么学习Python
因为做iOS开发的,之前一直用OC,但是突然有一天苹果说出Swift,但是那时候的Swift真的是Bug多多,语法都不固定,所以只是大致看了看,而一年多之后,Swift已经发布2.0了,语言也相对稳定 ...
- CentOS 6.3 安装以及配置Apache php mysql
准备篇: 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state –state NEW -m tcp -p tcp –dp ...
- C#取枚举描述
一直都觉得枚举是个很不错的东西,可以给我们带来很多方便,而且也增加代码的可读性. 我在之前已经介绍过枚举的简要应用了,再次再来写下怎么获取枚举的描述. 源码如下: 首先,我们定义个含有描述的枚举类型 ...
- ASP.NET Web API 实例
ASP.NET Web API 入门大杂烩 创建Web API解决方案,命名为VCoinWebApi,并且创建了同名的Project,然后,创建一个Empty Project:Models,创建一个W ...
- window窗口-button(按钮)-dialog(对话框,带按钮)
描述:一个可拖动的窗口程序,默认情况下窗口自由移动.调整大小.打开关闭! 案例1(普通的窗口): <div class="easyui-window" icon-Cls=&q ...
- C#开源大全--汇总(转)
商业协作和项目管理平台-TeamLab 网络视频会议软件-VMukti 驰骋工作流程引擎-ccflow [免费]正则表达式测试工具-Regex-Tester Windows-Phone-7-SDK E ...
- Asp.net开启分布式事务管理
1.确保服务器分布式管理服务 Distributed Transcation Coordinator 有开启 2.使用分布式事务代码的项目中添加System.Transactions程序集的引用 3. ...
- 我是如何基于angular+requirejs+node做SPA项目架构的
本文章已经录制视频,地址是:http://v.youku.com/v_show/id_XODI3MjYyODI0.html 前端这两年技术飞速发展,各种优秀框架层出不穷.本文不是讨论各框架的比较,也不 ...
- css3 的content 属性
content属性想必大家都熟悉了,一般结合伪类一起使用,表示显示的内容 例如:.box:before{content:"hello";width:100px;line-heigh ...
- Posix线程编程指南(2) 线程私有数据
概念及作用 在单线程程序中,我们经常要用到"全局变量"以实现多个函数间共享数据.在多线程环境下,由于数据空间是共享的,因此全局变量也为所有线程所共有.但有时应用程序设计中有必要提供 ...