ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <>
Subject Re: Perl filter task vs. filter/filterset/copy task
Date Tue, 27 Nov 2001 09:10:33 GMT
Sounds interesting. One thing I have wanted to do for a while is reimplement 
filters as a normal InputStream. So you could do something like

FilterOutputStream fos = ..;
//set some values to filter here
fos.setFilterVar( key, value );

FileUtils.copy( new FileInputStream("myfile.txt"), fos );

Then in theory your filter could be any implementation of output stream. 
Could your perlfilter work like that ?

On Tue, 27 Nov 2001 05:12, wrote:
> I must admit this work motivated by trying to create some build.xml files
> to run some
> automatic tests (instead of building a product), which might not be the
> primary purpose of Ant.
> I looked at Junit and extensions, the only problem I have with those
> environments is the way the test is marked
> as failed or passed (by asserts or exceptions thrown by the test code). I'd
> like much better the output of the test compared
> to a reference output with may be some filtering. It makes the test simpler
> to write (no code to write to check if test is
> ok) and it is more suitable for integration type of tests (tests more
> complex than unit tests).
> I created a perfilter task. I am not happy with the current design of this,
> since I believe that it should be a
> generalization of the filter/filterset used within a copy task (or
> something like that). I am currently looking into that, but
> I'd like the ant developer community input on that.
> The idea is to be able to take multiple files, filter them using the perl
> regexp "s/../../gimox" and generate multiple
> (or one) output files (using filset and mapper). I am using the oro-2.0.4
> for the perl expression processing. I defined
> a new task (perlfilter) and a new type (subst) in order to do that. You can
> find below some example of such task.
> The issues that I have when trying to generalize it into filter/filterset
> and copy are the following ones:
> 	- I am not sure that the subst type can be mapped easily into a
> filter type. The token/value attributes are
> too specific, I think.
> 	- the copy task with a merge mapper is not doing a merge (it is not
> a concat). It is just overwriting the tofile
> by each of the copied file (tofile will be equal to the last copied file).
> Not sure if this is a bug or if this is the way
> it is supposed to work (but merge mapper is a very confusing term, then).
> Thomas
> <perlfilter file="" tofile="test.out" overwrite="true"
> verbose="true">
>   <subst pattern=".*t" replacement="rr" />
> </perlfilter>
> <perlfilter tofile="test12.out" verbose="true" overwrite="true">
>   <fileset dir=".">
>     <include name="test.run1.out" />
>     <include name="test.run2.out" />
>   </fileset>
>   <subst pattern="/" replacement="\\" delimiter="#" />
> </perlfilter>
> <perlfilter todir="." verbose="true" overwrite="true">
>   <fileset dir=".">
>     <include name="test.run1.out" />
>     <include name="test.run2.out" />
>   </fileset>
>   <mapper type="merge" to="test.out" />
>   <subst pattern="/" replacement="\\" delimiter="#" />
>   <subst pattern=".*t" replacement="rr" />
> </perlfilter>



"Therefore it can be said that victorious warriors 
win first, and then go to battle, while defeated 
warriors go to battle first, and then seek to win." 
              - Sun Tzu, the Art Of War

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

View raw message