views:

40

answers:

1

http://ant.apache.org/manual/CoreTypes/mapper.html

here's my target:

 <target name="ms.copy-example">
  <copy todir="${ms.custom}">
   <fileset dir="${ms.example}">
    <include name="build.xml" />
   </fileset>
   <scriptmapper language="javascript">
     self.addMappedName("dir1/"+source);
     self.addMappedName("dir2/"+source);
     self.addMappedName("dir3/"+source);
   </scriptmapper>
  </copy>
 </target>

I'm trying to copy one file into 3 places. I don't care if I use a scriptmapper to do this, but I didn't see any other way to do it. What's actually happening, though, is that it's only copying the file into the first one in the list (dir1) and not the other two (dir2, dir3). Anyone have any ideas?

Thanks, Ben

+1  A: 

The scriptmapper is working, but by default, the copy task only copies to one (i.e. the first mapped) target. To get your example to work, add enablemultiplemappings="true" or similar to the copy:

<copy todir="${ms.custom}" enablemultiplemappings="true">

From the docs for copy task option enablemultiplemappings:

If true the task will process to all the mappings for a given source path. If false the task will only process the first file or directory. This attribute is only relevant if there is a mapper subelement. (since Ant 1.6.)

martin clayton
beautiful - thank you
andersonbd1