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
[EMAIL PROTECTED]



On Thu, Sep 11, 2008 at 10:48 AM, robert lazarski
<[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to