ant-user mailing list archives

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

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/**,"/>
        </exec>
        <javac srcdir="${src}" destdir="${build}"
            excludes="test/**, **/Test*, ${zonelist}"
            classpathref="myclass.path"
        />
        <javac srcdir="${src}" destdir="${buildzone}"
            excludes="test/**, **/Test*"
            includes="${zonelist}"
            classpathref="myclass.path"
        />
    </target>


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" />
So:
    <dirset dir="${src}">
        <include containsfile=".zone" />
    </dirset>
would include dirs that contain that exact filename.
and:
    <dirset dir="${src}">
        <include containsfile=".putinjar" containsline="*mykeyword*"/>
    </dirset>
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                                           zander@planescape.com
                                                 We are what we pretend to be

Mime
View raw message