You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Erik Hatcher <er...@earthlink.net> on 2001/09/01 15:50:17 UTC

Re: wild cards in replace task

I'm not sure if the <propertyfile> optional task would work for you or not,
but it seems the closest match to what you describe.    Here is an example:

    <propertyfile comment="Build Information"
file="${build.dir}/classes/version.properties">
        <entry key="version" value="${version}"/>
        <entry key="build.date" pattern="EEEE MMM dd, yyyy" type="date"
value="now"/>
        <entry key="build.time" pattern="kk:mm:ss" type="date" value="now"/>
        <!-- and yes, env.COMPUTERNAME is actually cross-platform because I
set its value from env.HOSTNAME if its not already set earlier in my build
file :) -->
        <entry key="build.host" value="${env.COMPUTERNAME}"/>
        <entry key="build.user.name" value="${user.name}"/>
        <entry key="build.os.name" value="${os.name}"/>
    </propertyfile>

While I am creating a file from scratch, the <propertyfile> task itself is
capable of editing the file in-place as well.

    Erik

----- Original Message -----
From: "Anthony Rodriguez" <An...@WeddingChannel.com>
To: <an...@jakarta.apache.org>
Sent: Thursday, August 30, 2001 9:09 PM
Subject: wild cards in replace task


> This question was replied to with a question from another topic.  So I'm
> sending it again:
>
> Is it possible to use wildcards in the token attribute of the replace
task?
> Say I have a file called text.txt that looks like this:
>
> text.txt:
> line1="blah blah blah";
> line2="something else";
>
> Now I want to use a replace task in my build.xml that looks like:
> ....
> <target name="replace"">
> <replace file="text.txt" value="line1=&quot; ${some.new.property}
&quot;;">
> <replacefilter token="line1=&quot; * &quot;;"/>
> </replace>
> </target>
> .....
>
> I want to use the * because I want to replace the whole line with a new
> line.  I won't always know the exact text in text.txt, so it would be more
> useful just to replace a whole line.  Is there a way to do this (I tried
the
> * and it didn't work)?  I tried to look for docs on replacefilter but I
> couldn't find any.  Any help would be greatly appreciated.
>
> -Anthony
>
>