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 是一个基于 ...
随机推荐
- ExtJS4.x 开发环境搭建
需要的资源 ExtJS4.2 eclipse 开发环境搭建 在项目中国需要引用的文件: eclipse中有报错.需要处理的是ext-lang-zh_CN.js,中文编码不能识别.右键->属性-& ...
- Win10无法上网提示缺少一个或者多个网络协议的处理方法
netsh winsock reset Win+x 再按A 输入 netsh winsock reset
- 可综合风格的VerilogHDL模块实例
1.赋值语句:assign{cout,sum}=a+b+cin; 2.利用电平敏感的always块设计组合逻辑电路 3.always块中如果含有局部变量,就必须在begin后加模块名,是必须加,同样的 ...
- java 静态变量生命周期(类生命周期)
Static: 加载:java虚拟机在加载类的过程中为静态变量分配内存. 类变量:static变量在内存中只有一个,存放在方法区,属于类变量,被所有实例所共享 销毁:类被卸载时,静态变量被销毁,并释放 ...
- SQL Server 2008 没有可用于 charge_sys_Log.LDF 的编辑器
因为上网问题重新装了系统.今天在整 SQL Server 的时候出现了这样一个问题. 因为之前装 SQL Server 的时候没有遇到过这种情况,感觉很新奇.所以详细的记录一下,希望对别人能有一定 ...
- C++中的抽象类及纯虚函数的实现与否
1.含有纯虚函数的叫抽象类 2.抽象类(一般是基类)中的纯虚函数无论函数体实现与否,都没有关系,系统会自动忽略 3.继承自抽象类的子类,必须要实现父类的纯虚函数才可以实例化对象 4.抽象类不允许实例化 ...
- 关于java.lang.OutOfMemoryError: Java heap space的错误分析
今天无意间遇到这个错误:java.lang.OutOfMemoryError: Java heap space 问题出现原因:使用a标签实现快速下载[当然已经实现了,但想了想还是要归纳解决这类问题] ...
- String str=new String("a")和String str = "a"有什么区别?
问:String str=new String("a")和String str = "a"有什么区别? 答:String str = "a" ...
- 【bzoj1012】[JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 8339 Solved: 3624[Submi ...
- 四大机器学习降维算法:PCA、LDA、LLE、Laplacian Eigenmaps
四大机器学习降维算法:PCA.LDA.LLE.Laplacian Eigenmaps 机器学习领域中所谓的降维就是指采用某种映射方法,将原高维空间中的数据点映射到低维度的空间中.降维的本质是学习一个映 ...