Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to <copy> in a <macrodef> in ant?

Tags:

ant

I'm trying to copy files in a macro, like so:

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

but I get the following

BUILD FAILED
b.xml:3: macrodef doesn't support the nested "copy" element.

Any ideas, other than "yes, indeeed, macrodef doesn't support the nested "copy" element." I got that much. I'm looking for why this limitation is here and a possible workaround (without using antcall).

like image 261
Trenton Avatar asked Aug 04 '09 16:08

Trenton


1 Answers

Try surrounding the <copy> element with <sequential>:

<macrodef name="copy-some-stuff">
   <attribute name="file.name" />
   <sequential>
      <copy todir="/var/tmp">
          <fileset file="@{file.name}" />
      </copy>
   </sequential>
</macrodef>
like image 181
Laurynas Biveinis Avatar answered Oct 03 '22 08:10

Laurynas Biveinis