ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kuiper, Arnout" <Arnout.Kui...@nl.origin-it.com>
Subject [PROPOSAL] Directory scanning into a helper class (reuse + improv ement)
Date Fri, 21 Jan 2000 14:26:39 GMT
Hi,

After updating the manual last night (and a number of questions
regarding Ant in my mailbox), I came to the conclusion that the
inclusion/exclusion of sets of files, is done separately by a bunch of
tasks, and could be improved a lot.

A lot of tasks have a base-directory, and a set of items that should
be included. Sometimes there is also an ignore attribute, to ignore
files/directories that have a certain name. Couldn't this be
standardized, made more flexible, etc...

I developed a helper class that given a basedir, a set of include
patterns and a set of exclude patterns, scans the given basedir, for
files that match one of the include patterns, and don't match any of
the exclude patterns. As a result the set of valid files is returned.

It could be used easily in the following tasks:
-copydir (inclusion/exclusion of files to copy)
-jar     (inclusion/exclusion of files to jar)
-javac   (inclusion/exclusion of files to compile)
-zip     (inclusion/exclusion of files to zip)

Also the creation of new tasks, that are based on a directory
structure, is much simpler.

Advantages:
-Tasks behave the same for the user.
-Easier to document in the manual.
-Better pattern matching.
-Less duplicated code.

Pattern matching is based on UNIX pattern matching. Matching is done
per directory name (name between two separators). In the pattern for
such a name, the following special characters can be used:
* matches zero or more characters
? matches one character
When the pattern for a directory name is '**', it matches zero or more
directories.
So "**/?d*.java" matches "xdyz.java", "test/ad.java",
"d1/d2/pdxxx.java", but not "x.java" (no 'd') and "test/xd.bat"
(no '.java').

What do you think of this?


Arnout Kuiper

Mime
View raw message