ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Elizabeth Cooper <>
Subject Ant Suggestion: FileSet by matching a String in the file
Date Tue, 27 Nov 2001 00:08:54 GMT
Suggestion for implementation: a way to do a FileSet or file list (to a 
file) from a positive match of a search for a String in a FileSet (or 
single file or src directory)

This is very much like a "grep" task with a designated output file for the 
matching file list (which can later be used as an includesfile or an 
excludesfile) and a String to match, and how many lines to search in the 
file (or search until another String is found, for example if you only want 
to search in the "header" area of source code, search until "public class" 
is found).

This can be done now with something like:

<apply executable="grep" output="filelist.txt">
             <arg value="-l"/>
             <arg value="-s"/>
             <arg value="Base-Package"/>
             <fileset dir="${src}" >
                 <include name="pkg/**/*.java"/>
                 <excludesfile name="files.exclude.txt" />

BUT there is a problem in that non-matches return a result of "1" which is 
displayed by ant (possible error), producing a really long list (in my 
case) of:

[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
[apply] Result: 1
..... etc, etc, etc.

This is quite a nuisance when you want to monitor what is going on with ant 
(logging, etc.).

P.S. I am doing this under Windows and there is no "quiet, -q" mode for 
grep, and I actually do not think that would work anyway.

ErgoTech Systems, Inc.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message