ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: a construct to ensure existence of files in collection?
Date Fri, 27 Oct 2006 16:45:09 GMT
On 10/27/06, Vladimir Egorov <vegorov@bea.com> wrote:
> Hi Ant Users,
>
> I am using FileList to specify collection of files one by one. I need to
> ensure that the specified files exist.
>
> According to FileList doc, "FileLists are useful for specifying files
> that may or may not exist". I checked some other path-like structures,
> but did not find a straight-forward way to do this.
>
> Is there something obvious I am missing? Any recommendations besides two
> approaches listed below?

I do not know any.

>
> One approach is to enhance FileList with a 'failonerror' attribute, e.g.
>
> <filelist dir='some/dir' failonerror='true'>
>   <file name='some.file'/>
> </filelist>
>
> (also for individual <file name='some.file' failonerror='true'/>).
>
> Another approach is to provide an assert task for the same, e.g.
>
> <assertFilesExist>
>   <filelist dir='some/dir'>
>     <file name='some.file'/>
>   </filelist>
> </assertFileExist>
Here is an implemenation of this:
  <macrodef name="assertFilesExist" backtrace="no"
     xmlns:ac="antlib:net.sf.antcontrib">
    <element name="filelist" implicit="yes"/>
    <sequential>
      <ac:for param="file">
        <filelist/>
        <sequential>
          <ac:if>
            <available file="@{file}"/>
            <else>
              <fail>File @{file} does not exist</fail>
            </else>
          </ac:if>
        </sequential>
      </ac:for>
    </sequential>
  </macrodef>

(Just one problem, need a backtrace="no" attribute for <ac:for>).

Peter

>
> (also for reference <assertFilesExist refid='someref'/>).
>
> Thank you,
>
> --Vladimir
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

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


Mime
View raw message