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 是一个基于 ...
随机推荐
- iOS 进阶 第十七天(0420)
0420 凡是继承了UIResponder的类都可以做响应者 响应事件的传递是由底到高来传递,响应者链条是由高到底来响应 相应事件的传递(由底到高 找到正在和用户触摸交互的view) 准则:事件由父控 ...
- Lua与C++交互初探之Lua调用C++
Lua与C++交互初探之Lua调用C++ 上一篇我们已经成功将Lua的运行环境搭建了起来,也成功在C++里调用了Lua函数.今天我来讲解一下如何在Lua里调用C++函数. Lua作为一个轻量级脚本语言 ...
- 20145129 《Java程序设计》第5周学习总结
20145129 <Java程序设计>第5周学习总结 教材学习内容总结 语法与继承架构 使用try.catch Java中所有错误都会被打包为对象,可以尝试(try)捕捉(catch)代表 ...
- Java 7 中 NIO.2 的使用——第一节 Path 类的使用
路径隶属于文件系统,实际上它是存储和组织媒体文件的格式,通常在一块或多块硬盘设备上,以便于非常容易地检索.文件系统可以通过 java.nio.file.FileSystems 这个final 类来访 ...
- Poj 1904 King's Quest 强连通分量
题目链接: http://poj.org/problem?id=1904 题意: 有n个王子和n个公主,王子只能娶自己心仪的公主(一个王子可能会有多个心仪的公主),现已给出一个完美匹配,问每个王子都可 ...
- 【CentOs】sudo使用
在使用Linux系统过程中,通常情况下,我们都会使用普通用户进行日常操作,而root用户只有在权限分配及系统设置时才会使用,而root用户的密码也不可能公开.普通用户执行到系统程序时,需要临时提升权限 ...
- Python大数据依赖包安装
一.安装 先安装python2.7.6,win下的numpy这些包需要直接匹配版本,然后安装“numpy-1.8.1-win32-superpack-python2.7”和“scipy-0.16.0- ...
- HDU1048The Hardest Problem Ever
The Hardest Problem Ever Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- 我的第一款windows phone软件
我的第一个windows phone应用发布成功了,大家支持下,名字叫吕氏春秋,发布人是我的英文名xmfdsh http://www.windowsphone.com/zh-cn/store/app/ ...
- 使用Assetbundle时可能遇到的坑
原地址:http://www.cnblogs.com/realtimepixels/p/3652128.html 一 24 十一郎未分类 No Comments 转自 http://www.unity ...