ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: Filtering on ${} instead of @@
Date Thu, 11 Sep 2008 15:29:16 GMT
Can you use <filter> without first creating a filterset?

I always thought it was this:

<target name="filter_me">
    <property file="filter_me.properties"/>
    <copy todir="target/somedir" filtering="true" overwrite="true" >
	<filterset>
	    <filter token="foo" value="${foo}" />
	</filterset>
	<fileset dir="src">
	    <include name="*.txt*"/>
	</fileset>
    </copy>
</target>

When you define a filterset, you can define a begintoken and endtoken:

<target name="filter_me">
    <property file="filter_me.properties"/>
    <copy todir="target/somedir" filtering="true" overwrite="true" >
	<filterset>
	    <filter token="foo" value="${foo}" />
	</filterset
             begintoken="${"
             endtoken="}">
	<fileset dir="src">
	    <include name="*.txt*"/>
	</fileset>
    </copy>
</target>

This might not work because of your choice of symbols. You'll have to
play around a bit. Try doubling the "$" or "&#36;&#123;" and "&#125"
which are the XML character codes for "${" and "}".

--
David Weintraub
qazwart@gmail.com



On Thu, Sep 11, 2008 at 10:48 AM, robert lazarski
<robertlazarski@gmail.com> wrote:
> Hi all, I searched the archives but couldn't find a solution. For
> example, I have a file named filter_me.txt with its contents:
>
> ${foo}
>
> In filter_me.properties I have:
>
> foo=bar
>
> I'd like to use a simple filter like:
>
>  <target name="filter_me">
>        <property file="filter_me.properties"/>
>        <filter token="foo" value="${foo}" />
>        <copy todir="target/somedir" filtering="true" overwrite="true" >
>                <fileset dir="src">
>                <include name="*.txt*"/>
>        </copy>
>  </target>
>
> Is there any way to replace "${foo}" with "bar" via ant as shown in
> this example ? I can't use @foo@ for non-tecnical reasons.
>
> Thanks,
> Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message