ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sony Antony <>
Subject Re: Overriding ant <copy> task
Date Mon, 05 Jul 2010 23:11:33 GMT
Thank you David :
Your sugegstion as it is will not work for me as once I copy teh
files, I wont have teh names ( I mape them ).
But Im convinced that your approach in general is better than changing
eth source code.

So I decided to use filter chains.

Basically I m trying to first copy the files in one filterreader, and
the next one will check if there are still unexpanded tokens left.

I have the following problems now :
1. What is teh equivalent filter reader for the folloing
<filterset begintoken="@" endtoken="#" filtersfile="props" recurse="true"/>

Following works only in ant 8.1 ( I found out about propertiesresource
after reading teh sourcecode )
          <replacetokens begintoken="@" endtoken="#"

2. I couldnt find any filterreader corresponding to <fail> ( I want to
do a <tokenfilter> /<containsregex> and trigger failure if there are
tokens still left )
Do I need to write a new filterreader  that will throw a
BuildException() for this ?



On Mon, Jul 5, 2010 at 1:39 AM, David Weintraub <> wrote:
> Seems like a lot of work. Why not do the <copy> task with the filter,
> then use a mechanism to test the copied files to see if any tokens
> exist. You can use the <concat> command with the <containsregex>
> filter to see if any tokens (Pattern = /@\w+@/) exists in the files
> just copied.
> If you do find such files exist, you can fail the build.
> On Sun, Jul 4, 2010 at 7:17 PM, Sony Antony <> wrote:
>> Hi :
>> Im trying to modify the <copy> task so that if a token seen in the
>> file being copied, is undefined in teh <filterset>, the build will
>> fail..
>> ( It will also list all teh undefined tokens encountered against the
>> corresponding file name )
>> 1. Was there an way to do this without writing java code ?
>> 2. I have already made the changes required in teh ant source code.
>> But I cant figure out how to execute my code.
>> I created a jar file with just the changed class files, and did a
>> <taskdef> with this jar file.
>> But none of my files got executed.
>> Since my class files were packaged just like teh original ant
>> classfiles, it appeard that ant ignored them completely thinking that
>> those class files have already been loaded.
>> Is there a way around it so that class files seen inside my jar file
>> will be picked up first and the remaining files will be resolved from
>> the original ant classloader
>> Thanks
>> --sony
>> Files being changed and packaged inside antfix.jar
>> apache-ant-1.8.1/src/main/org/apache/tools/ant/taskdefs/
>> apache-ant-1.8.1/src/main/org/apache/tools/ant/types/
>> apache-ant-1.8.1/src/main/org/apache/tools/ant/types/
>> apache-ant-1.8.1/src/main/org/apache/tools/ant/util/
>> <taskdef name="copy2" classname=""
>> classpath="/path/to/antfix.jar"/>
>> Doesnt work :
>> <target name="try">
>>        <copy2 file="srcfile" toFile="destfile">
>> <filterset begintoken="@" endtoken="#">
>> <filter token="TOK1" value="VAL1"/>
>> <filter token="TOK2" value="VAL2"/>
>> </filterset>
>>        </copy2>
>>        </target>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> --
> David Weintraub
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message