You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Mariusz Nowostawski <ma...@marni.otago.ac.nz> on 2000/05/04 06:10:19 UTC

[patch] exec task for list of files

Hey, following the discussion about 'execFor' functionality I wrote a
trivial extension to the existing exec task definition. With the patch,
the exec task will behave as usual if used as usual. However, if used with
the additional optional attribute 'src' which should be a directory, will
search for files, and will exec a command with attached list of files as
an additional last argument.


Examples:
(*) <exec dir="/tmp" command="ls -l" output="out.txt"/>
will execute effectively as usual
cd /tmp; ls -l


(*) <exec dir="${basedir}" 
      command="jidl --output-dir ${src.dir} --package com.my.idl" 
      src="src/idl" output="out.txt"/>
and if inside ${basedir}/src/idls we have files: a.idl, b.idl, c.txt
will execute effectively:
cd ${basedir}; jidl --output-dir src/main --package com.my.idl \
${basedir}/src/idl/a.idl ${basedir}/src/idl/b.idl ${basedir}/src/idl/c.txt


(*) <exec dir="${basedir}"
      command="jidl --output-dir ${src.dir} --package com.my.idl"
      src="src/idl" output="out.txt">
      <include name="*.idl"/>
    </exec>
and if inside ${basedir}/src/idls we have files: a.idl, b.idl, c.txt
will execute effectively:
cd ${basedir}; jidl --output-dir src/main --package com.my.idl \
${basedir}/src/idl/a.idl ${basedir}/src/idl/b.idl


The patch assumes that the command should be invoked once with the list of
all matching files as last attribute. I cannot find a use of executing
commands in list of files sequentially file after file with unknown order,
but if somebody needs it, the patch can be easily extended (i.e. exec 
task can be easily extended). Maybe there are usefull file/source
processors which can deal with single file only at once...


----
best regards
Mariusz