ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Zander <>
Subject Extending the include/exclude dirset
Date Sun, 30 Jun 2002 14:07:28 GMT

I'd like to include/exclude files from a dirset based on files being present 
in a directory.
So a directory that contains a placeholder file should get included in the
dirset, and others should not.

Something like this:

    <target name="compile" depends="init">
        <exec executable="find" dir="${src}" outputproperty="zonelist">  <!-- create
patterslist of all zone packages -->
          <arg line="com"/>
          <arg line="-name .zone"/>
          <arg line="-type f"/>
          <arg line="-follow"/>
          <arg line="-printf %h/**,"/>
        <javac srcdir="${src}" destdir="${build}"
            excludes="test/**, **/Test*, ${zonelist}"
        <javac srcdir="${src}" destdir="${buildzone}"
            excludes="test/**, **/Test*"

The exec creates a list like;
    com/foo/**, com/bar/**,
in the property 'zonelist'.

First question; can this be done nicely without the (OS specific) exec?

This was the easy part :)  I'd like to extend this by allowing only dirs
to be allowed in a dirset that contain a certain file AND that file contains
a certain line.  I have not found a good way to do that, even with find.
Any ideas?

My solution to this problem would be to extend the <include> tag to allow 2 
extra tags;
    <include containsfile="filename" containsline="regexp" />
    <dirset dir="${src}">
        <include containsfile=".zone" />
would include dirs that contain that exact filename.
    <dirset dir="${src}">
        <include containsfile=".putinjar" containsline="*mykeyword*"/>
would include dirs that contain the '.putinjar' file which must contain the
wildcard given in the containsline argument.

if that sounds like a good idea, can you guys help me do it, I failed to find
where this should be implemented, I got as far as the PatternSet.NameEntry
where I wanted to extend the valid() method.

Many thanx!

Thomas Zander                                 
                                                 We are what we pretend to be

View raw message