ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Slass <>
Subject Re: pointer on making <copy> fail on file not found
Date Wed, 26 Jun 2002 15:00:02 GMT
Diane Holt <> writes:

>--- Michael Slass <> wrote:
>> I'd like to add the capability to make a copy task fail if either
>> 1) an explicitly named source file in any of the nested filesets,
>>    mentioned either in an includes attribute, or a nested include tag
>>    does not exist.
>For explicitly named files, run an <available> on them, and <fail> if the
>property's not set. (If running 1.5, <fail unless="propname".../>.)
>> 2) Any of the wildcard entries specified in the above ways matches
>>    nothing.
>Define a <fileset>, <pathconvert> it to a property, and <fail> if the
>property's not set -- ie., the <fileset> is empty (for 1.5Beta3 -- for
>earlier versions, you'd need to include a <condition> that tests if the
>property is equal to "").


Thanks for the workaround; I agree that your solution will work, but
it seems a bit cumbersome in terms of additional tags added to

The solution I envision would allow the failure to occur if any files
or filesets in a copy task were not found, just by modifying the copy

<!-- set strictfind property based on command-line args -->

<copy todir         = "some/target/dir"
      mustfindfiles = "${strictfind}">  <!-- NEW ATTRIBUTE -->
    <fileset dir = "some/source/dir/foo">
        <include name = "**/*.class"/>
        <include name = "README"/>
        <include name = "LICENSE"/>
        <include name = "GPL"/>
        <include name = "INSTALL"/>
        <include name = "COPYING"/>
    <fileset dir      = "another/source/dir"
             includes = "gomer.txt, flomer.txt"/>

In this instance, I'd like it to fail if any of the explicitly-named
files are not found, or if there are no .class files found under the
foo directory, just by setting the strictfind property to "true".

Even in this small example, using the workaround I would need 7
<available> tasks, each with a corresponding property and <fail> task,
and then a <pathconvert>, property, and <fail> for the wildcard
match.  My build.xml would get unreadable in a hurry.

Again, I've posted to the dev list, because I'm quite willing to take
a crack at hacking the ant code to do this.  I do, however, need some
pointers at where I should be looking.

Thanks again.

Mike Slass

,----                       WRQ, Inc.
| We specialize in integration software and services that let you
| quickly adapt your host-intensive environment to meet new business
| needs.

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

View raw message