ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant Reddy <>
Subject Re: AW: Fail build when 'replace' task cannot find expected number oftokens
Date Tue, 05 Feb 2008 12:54:28 GMT
Thanks for a good idea. nice and simple.

Quick check with following build.xml reveals that the replace does not
modify timestamp even when token is replaced. However this approach will
not catch scenario where 1 instance was replaced when 2 were expected. 

<?xml version="1.0" encoding="UTF-8"?>
<project name="test-replace" default="test">
    <target name="test">
	<echo file="source.txt" message="token"/>
        <copy file="source.txt" tofile="temp.txt"
        <replace file="temp.txt" token="token" value="replaced"/>
        <condition property="not.replaced">
                <uptodate srcfile="source.txt"
        <fail if="not.replaced" message="Not replaced"/>

$ ls -lt
total 12
-rw-r--r-- 1 prashant prashant   5 2008-02-05 18:22 source.txt
-rw-r--r-- 1 prashant prashant   8 2008-02-05 18:22 temp.txt
-rw-r--r-- 1 prashant prashant 569 2008-02-05 18:22 build.xml


On Tue, 2008-02-05 at 13:27 +0100, Knuplesch, Juergen wrote:
> Maybe you could copy the file without changing of the timestamp (attribute preservelastmodified).
> Then do the replace on your file.
> Then test via <uptodate> if a change happened.
> Delete the copy
> This will only work, if replace does not change the timestamp, in case of no changes.
> Just an idea...

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

View raw message