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 是一个基于 ...
随机推荐
- 【转】VNC配置
配置VNC服务参数文件 编辑vncservers文件追加如下 #vi /etc/sysconfig/vncsevers VNCSERVERS="1:root" VNCSERVERA ...
- iOS开发的22个奇谲巧技
结合自身的实践开发经验总结出了22个iOS开发的小技巧,以非常欢乐的语调轻松解决开发过程中所遇到的各种苦逼难题,光读着便已忍俊不禁. 1. TableView不显示没内容的Cell怎么办? 类似于图1 ...
- Android开发随笔之ScrollView嵌套GridView[ 转]
今天在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便会出问题,即GridView会显示不全,为了解决这个问题查了N多资料,某个谷歌的 ...
- C++函数的参数传递机制以及参数的类型选择
C++primer之函数的参数传递以及参数的类型 一:函数的基本知识 (1) 函数要素:返回类型,函数名字,形参(参数之间用逗号隔开) (2) 函数调用机制:我们通过调用运算符来执 ...
- Java Day 11
异常 Throwable 子类 Error.Exception Error - 不可以处理 Exception - 针对性处理 原理 自定义异常 异常类的抛出throws 先检查语法错误,后检查逻辑 ...
- 团队项目--“我爱淘”校园二手书店 NABC分析
本项目的特点之一:可查询功能 NABC分析: N(Need):方便校园里的学生查找自己需要的二手书籍,免了同学想买二手书还得跑到阿姨那里去看. A(Approach):将学生的信息和书籍的信息都存放在 ...
- SVG基本图形及clipPath;
利用SVG可以实现很多复杂的图形,SVG的功能开发者们已经开发许多,今天初识一下SVG的基本图形绘制, <svg viewbox="0,0,400,400" style=&q ...
- 升级ubuntu内核
ubuntu12.04内核为 linux-image-3.5.0-23-generic 要升级为 linux-image-3.2.0-57-generic 使用apt-get install linu ...
- 提取html中的src 路径
/// <summary> /// 替换body中的img src属性 附加上域名 /// </summary> /// <param name="str&qu ...
- SQL 语法 Join与Union
问题描述: Join与Union使用 问题解决: Join连接,可以分为: tableA如下: tableB如下: 1.1.Inner Join SELECT * FROM TableA INNER ...