我正在尝试在宏中复制文件,如下所示:
<project name="why" default="go">
<macrodef name="copy-some-stuff">
<attribute name="file.name" />
<copy todir="/var/tmp">
<fileset file="${file.name}" />
</copy>
</macrodef>
<target name="go">
<copy-some-stuff file.name="/etc/hosts" />
</target>
</project>
但我得到以下
BUILD FAILED
b.xml:3: macrodef doesn't support the nested "copy" element.
除了“是的,确实,macrodef 不支持嵌套的“复制”元素之外的任何想法。我得到了那么多。我正在寻找为什么会出现此限制以及可能的解决方法(不使用
antcall
)。
最佳答案
尝试围绕 <copy>
带有 <sequential>
的元素:
<macrodef name="copy-some-stuff">
<attribute name="file.name" />
<sequential>
<copy todir="/var/tmp">
<fileset file="@{file.name}" />
</copy>
</sequential>
</macrodef>
关于ant - 如何在ant的<macrodef>中<copy>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1228637/