使 ANT 宏更具可重用性
我有一个简单的宏(下面的简化版本)。目前,它假设单个参数只有一个值,但该参数可能有多个值。如何为该参数传入 0+ 值,以便在需要为该参数传入 0+ 值(而不仅仅是单个值)的情况下可以使用宏
<macrodef
name="test">
<attribute name="target.dir" />
<attribute name="arg.value" />
<sequential>
<java jar="${some.jar}" dir="@{target.dir}" fork="true" failonerror="true">
<arg value="-someargname=@{arg.value}"/>
</java>
</sequential>
</macrodef>
I have a simple macro (simplified version below). At the moment it assumes that there will be a single value for a single argument, however there might be multiple values for that argument. How can I pass in 0+ values for that argument so that the macro is usable in situations where I need to pass in 0+ values for that argument, not just a single value
<macrodef
name="test">
<attribute name="target.dir" />
<attribute name="arg.value" />
<sequential>
<java jar="${some.jar}" dir="@{target.dir}" fork="true" failonerror="true">
<arg value="-someargname=@{arg.value}"/>
</java>
</sequential>
</macrodef>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,您可以通过以下两种方法之一来完成此操作。您可以将文件集等集合作为属性传入,然后根据需要引用它们,也可以将集合作为元素传入并使用元素名称引用它们。
Turns out you can do this one of two ways. Either you can pass in collections such as fileset as attributes then reference them as needed, or you can pass in collections as elements and reference them using the element name.