ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <DDevie...@lgc.com>
Subject RE: testing for the existence of a file...
Date Mon, 26 Jul 2004 14:49:00 GMT
> From: Alan Brown [mailto:abrown@symyx.com]
> 
> Maybe I didn't explain my situation properly, or maybe I just couldn't
> see how uptodate helps me.
> 
> I'm creating, during my build process, a tree of directories, the leaf
> nodes of which will have files of type .xyz.
> 
> I wish to use subant to run a standard build file against all
> directories that contain .xyz files.  I'm therefore using the
> genericantfile attribute and the direst element to define the set of
> directories.  Currently I'm just setting the dir attribute of the
direst
> element to 'root' so the subant task will run my generic buildfile
> against all directories under 'root'.
> 
> Therefore, when running the sub build file I need to first see if
there
> is a file of type .xyz.  If there isn't then the rest of the build
> process is aborted.
> 
> I've used uptodate before and am familiar with it, but I don't see how
> it can help my situation as I am not comparing the last modified dates
> of a target and a source.

Then if I understand you correctly, what you want is refine your
<dirset> to only contain directories which contain a specific type of
files (.xyz). This way you never have to abort a build when no such
files are there, because a build won't be started in the first place!

Here's an example of mine that's close:

    <dirset id="-docdirs" dir="${javadocs}">
      <include name="*" />
      <present targetdir="${javadocs}" present="both">
        <mapper type="regexp" from="(.*)" to="\1/index.html" />
      </present>
    </dirset>

This selects all directories from ${javadocs} which contain an
index.html file. Unfortunately, it's not quite what you want, because
the technique above requires you to know the exact name of the file
you're looking for, and you cannot use an Ant patternset-like pattern
(e.g. *.xyz).

Then you're back to using all the dirs, and try to figure out if you
should do something. Then you create a fileset of your *.xyz files,
convert it to a string (with <property refid> in Ant 1.6+ or
<pathconvert> otherwise), and see if the string is empty
(<condition><equals>). If it is, you don't do anything.

Not much more I can say since the description of your process is quite
generic. --DD

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


Mime
View raw message