ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Ant Wiki] Update of "AntSampleFiles/ApplyRedirectorExample" by GeorgeBerger
Date Sat, 23 Feb 2008 17:25:20 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ant Wiki" for change notification.

The following page has been changed by GeorgeBerger:

New page:
Redirector example: copies files by execing 'cat' with input redirected from source file src/*.src
and output redirected to dest/*.out.

<project default="copycat">

  <target name="copycat">
     <apply executable="cat" addsourcefile="false">
           <mapper type="glob" from="*.src" 
               to="dest${file.separator}*.out" />
           <mapper type="glob" from="*" to="src${file.separator}*"/>
       <fileset dir="src" includes="*.src" />
       <mapper type="glob" from="*.src"
               to="dest${file.separator}*.out" />


This uses three mappers and a fileset.  The fileset identifies the files to be processed.
 The fileset's dir attribute tells it what directory the files are in.  The fileset produces
a list of source files, e.g. "a.src" "b.src", that are used by the mappers.

The apply task's mapper is used to determine which files are already up to date.  It maps
each *.src file to dest/*.out.

Note that ${file.separator} must be used if you need this to work cross-platform.  Mapper
doesn't do the slash-backslash translation for you.

The mapper used by outputmapper identifies the file to redirect output to.  It maps each *.src
file to dest/*.out.  This is the same mapping the apply task uses for determining dependencies.
Alternately you could define a single mapper and reference it using refid for both of these

The mapper used by inputmapper just maps each source file '*' to the file with the same name
in the src directory, 'src/*'.  This is essentially an identity mapping, but the files passed
to the mapper consist of just the filename, so the directory name needs to be prepended to
pick up the right file.

By default, the apply task passes the source file name as a command line argument to its executable
for each execution.  We need to inhibit this behavior for this example by setting the addsourcefile
attribute false, so that cat will take input from the input redirect instead of reading the
named file.  (The result would be the same in this case, but we're trying to demonstrate input

View raw message