You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Iván Pérez Domínguez <iv...@gmail.com> on 2006/10/09 22:19:40 UTC

Loop over a set of files

Hi there!

I've written a macrodef that takes a file name as an argument and tests
it with a specific command. I'd like to run this macrodef over a set of
files, but the program I test can only get one input file at each time.
I'd also like to be able to use pattern matching, such as "*.o" or
"*.cpp" for these input files.

Is there any existing task that can help me on this purpose? Do I have
to write my own ANT loop-over-fileset task in Java to do it?

Cheers

Re: Loop over a set of files

Posted by Peter Reilly <pe...@gmail.com>.
An example loop over files:

<project default="test" xmlns:ac="antlib:net.sf.antcontrib">
  <macrodef name="processfile">
    <attribute name="file"/>
    <sequential>
      <echo>Process @{file}</echo>
    </sequential>
  </macrodef>

  <target name="test">
    <ac:for param="file">
      <fileset dir="." includes="**/*.xml"/>
      <sequential>
        <processfile file="@{file}"/>
      </sequential>
    </ac:for>
  </target>
</project>

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Loop over a set of files

Posted by Daniel Blaukopf <Da...@Sun.COM>.
Hi Iván,


Can you write your macro to accept a fileset instead of a specific file?
And then us <apply parallel="false"> to run the command?


Daniel


Iván Pérez Domínguez wrote:

> Hi there!
>
> I've written a macrodef that takes a file name as an argument and tests
> it with a specific command. I'd like to run this macrodef over a set of
> files, but the program I test can only get one input file at each time.
> I'd also like to be able to use pattern matching, such as "*.o" or
> "*.cpp" for these input files.
>
> Is there any existing task that can help me on this purpose? Do I have
> to write my own ANT loop-over-fileset task in Java to do it?
>
> Cheers
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Loop over a set of files

Posted by Mathieu Champlon <m....@free.fr>.
Hello,

The <for> task from ant-contrib is probably what you are looking for : 
http://ant-contrib.sourceforge.net/tasks/tasks/for.html

MAT.

Iván Pérez Domínguez a écrit :
> Hi there!
>
> I've written a macrodef that takes a file name as an argument and tests
> it with a specific command. I'd like to run this macrodef over a set of
> files, but the program I test can only get one input file at each time.
> I'd also like to be able to use pattern matching, such as "*.o" or
> "*.cpp" for these input files.
>
> Is there any existing task that can help me on this purpose? Do I have
> to write my own ANT loop-over-fileset task in Java to do it?
>
> Cheers
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org