ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier Croisier" <>
Subject Re: Looping/exception handling in Ant project
Date Mon, 06 Sep 2004 14:18:36 GMT
You're right, it could be hard to justify the use of Ant if it can't even handle multiple files...

Another idea :
Did you try to extend your Task from Ant's MatchingTask ?
This Task is specialized in processing multiple files, and seems to match your needs.
I think it could make the need of an external batch, history :)
Though, I don't know if it will process the selected files one after another, or launch many
processes simultaneously (but I don't think so).

See if it can help you ?


On Mon, 6 Sep 2004 14:46:37 +0100, Hobbs, Gareth <> wrote:

> Many thanks Olivier.
> I had thought of that (or doing the same in a Java program) and it could be
> the best solution. However, architecturally I had hoped to accomplish
> everything using Ant. It is harder to justify using Ant at all for this
> application if I cannot meet all the polling and pipeline management
> requirements without additional coding.
> Cheers,
> Gareth
> -----Original Message-----
> From: Olivier Croisier []
> Sent: 06 September 2004 13:39
> To: Ant Users List
> Subject: Re: Looping/exception handling in Ant project
> Have you tried outsourcing the problem ?
> I mean, to use your OS's batch commands to loop on the directory's files and
> call ant for each of them, rather than looping from within your ant task ?
> With linux's bash it can be done very easily. For example :
> for i in *.input; do ant -file "$i"; done;
> (assuming your files are named with a ".input" extension, and your ant task
> takes a -file argument to designate the file to work on...  You get the
> idea.)
> This must also be possible using the Windows "shell"...
> Hope this helps,
> Olivier
> On Mon, 6 Sep 2004 13:21:05 +0100, Hobbs, Gareth
> <> wrote:
>> Hi,
>> I am using Ant to automate a processing pipeline - an Ant project is used
> to
>> define a sequence of processing steps to be applied to an input file
>> (usually by way of a target containing an XSLT task). If all steps
> succeed,
>> the last target in the project generates a "success" output document. If
> any
>> step fails, causing the project to fail, a custom subclass of
> DefaultLogger
>> generates a "failure" output document.
>> This works well for a single input file - I currently pass the input
>> filename property to the project as a command-line argument.
>> However, I need to execute the pipeline iteratively over multiple input
>> files - a specific input directory may contain more than one file matching
> a
>> given pattern. I can't process all files within each target, as there are
>> assumptions made that only one file is being worked on, such as when
> naming
>> temporary files created by one target and picked up by the next.
>> I also need to preserve my exception handling - should the pipeline fail
> for
>> a particular input file, then the "success" and "failure" processing
>> outlined above should apply, but then the project should move onto the
> next
>> matching file instead of terminating.
>> At present I can only think of creating an outer project that calls the
>> existing project within a loop (using <foreach>) and an exception handler
>> (using <trycatch>). I am not sure of the release status of the cc-contrib
>> code and whether its appropriate to use this within my validated
>> application. In any case, I would prefer to solve this declaratively
> rather
>> than procedurally!
>> Your thoughts and suggestions gratefully received!
>> Thanks,
>> Gareth
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:

Software Engineer
Thales IS - ANS

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message