You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Thomas Zander <za...@planescape.com> on 2002/06/30 16:07:28 UTC

Extending the include/exclude dirset

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

Re: Extending the include/exclude dirset

Posted by Diane Holt <ho...@yahoo.com>.
--- Thomas Zander <za...@planescape.com> wrote:
> I'd like to include/exclude files from a dirset based on files being
> present in a directory.
[snip]
> 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.

If you're running 1.5, you could look into extending the Selectors stuff.
While it looks like <dirset> allows for a nested <selector>, so far it
also looks like all the core selectors deal with producing a fileset
(unless I just haven't read it right). (Of course, when all else fails,
you can always just fall back on "scripty" things like <script> or
<foreach> :)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>