1
votes

Based on http://ant.apache.org/manual/Types/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 to three places. I don't have to use a 'scriptmapper' to do this, but I didn't see any other way to do it. What's happening, though, is that it's only copying the file into the first directory in the list (dir1) and not the other two (dir2, dir3).

Anyone suggestions?

1

1 Answers

2
votes

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