如何将列表中的每个元素分配给一个任务蚂蚁的论点? [英] How to distribute each element of a list to argument of a task Ant?

查看:195
本文介绍了如何将列表中的每个元素分配给一个任务蚂蚁的论点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何采取论据定义任务的值转换成无(值)列表,以便重写任务参数的每个值?

How to take the values of argument for a defined task into a list (of values) without to have to rewrite the task for each value of argument ?

例如:
我想避免不得不重写三个时间回送三个不同的值(值1,值2,值3)相同的任务:

Example: I want to avoid to have to rewrite three time the same task for echoing three different values (value 1, value 2, value 3):

<exec executable="cmd">
	<arg value="/c"/>
	<arg value="value 1"/>
</exec>

<exec executable="cmd">
	<arg value="/c"/>
	<arg value="value 2"/>
</exec>

<exec executable="cmd">
	<arg value="/c"/>
	<arg value="value 3"/>
</exec>

感谢

推荐答案

您可以使用 MacroDef 任务您的任务抽象的公共部分:

You could use the MacroDef task to abstract the common part of your task:

<macrodef name="myMacro">
    <attribute name="value"/>
    <sequential>
         <exec executable="cmd">
             <arg value="/c"/>
             <arg value="@{value}"/>
         </exec>
    </sequential>
</macrodef>

<myMacro value="value 1"/>
<myMacro value="value 2"/>
<myMacro value="value 3"/>

这篇关于如何将列表中的每个元素分配给一个任务蚂蚁的论点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆