如何在ant?</macrodef> </copy>中的<macrodef>中<copy>

时间:2009-08-04 16:46:54

标签: ant

我正在尝试复制宏中的文件,如下所示:

<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.

除了“yes,indeeed,macrodef之外的任何想法都不支持嵌套的”copy“元素。”我得到了那么多。我正在寻找为什么这个限制在这里和一个可能的解决方法(不使用antcall)。

1 个答案:

答案 0 :(得分:9)

尝试使用<copy>围绕<sequential>元素:

<macrodef name="copy-some-stuff">
   <attribute name="file.name" />
   <sequential>
      <copy todir="/var/tmp">
          <fileset file="@{file.name}" />
      </copy>
   </sequential>
</macrodef>
相关问题