You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Geoff Meakin <ge...@gamesys.co.uk> on 2005/09/01 16:39:36 UTC

filtersets problem

Hi all, 
Hoping someone can help me with this frustrating problem.

I have:
1) a file to be copied with a @TOKEN1@ in it, 
2) a property: <property name="TOKEN1value" value="foo"/> , and
3) a filter to connect them:
<filterset>
  <filter token="TOKEN1" value=${TOKEN1value}"/>
</filterset>

Hey presto it works, and @TOKEN1@ gets replaces with foo

However, Im trying to use a filterset as defined in a file, i.e.
<filtersfile> with entries such as:

TOKEN1=${TOKEN1value}

This doesn't work, @TOKEN1@ merely gets replaces with '${TOKEN1value}'
(literally), and the subsequent replace with the property value does not
happen. I didn't expect this but thought ok, maybe nobody's thought of
this. (Properties files work fine with in-file replacing, but Filters
files seem not to)

I then looked into filterchains, and set up a filterchain composed of:

      <filterchain>
        <tokenfilter>
          <replaceregex pattern="\@(.*)\@" replace="${\1}" flags="gi"/>
        </tokenfilter>
        <expandproperties/>
      </filterchain>

This doesn't work either.- the expandproperties gets ignored, despite
this is what filterchains were invented for..

I've tried using the recurse param on a filterset, I've tried just about
everything, and cant get a @TOKEN@ to be replaced with a property value,
if the filter token comes from a file.

Any help from someone who has solved this would be great, just about
tearing my hair out (:-) I have about 50 billion tokens to replace, and
would prefer them to be in a file rather than build.xml as build.xml is
not an appropriate place for them. Some of these tokens should be
replaced with the value of a property at runtime. 

Ant 1.6.5
Ant-contrib-1.0b2

Thanks
-Geoff




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


Re: filtersets problem

Posted by Juergen Hermann <jh...@web.de>.
On Thu, 1 Sep 2005 15:39:36 +0100, Geoff Meakin wrote:

well, why don't you <copy> the filertsfile into a temp file using 
expandproperties, and then use the COPY as the filtersfile?

>Hi all, 
>Hoping someone can help me with this frustrating problem.

>I have:
>1) a file to be copied with a @TOKEN1@ in it, 
>2) a property: <property name="TOKEN1value" value="foo"/> , and
>3) a filter to connect them:
><filterset>
>  <filter token="TOKEN1" value=${TOKEN1value}"/>
></filterset>

>Hey presto it works, and @TOKEN1@ gets replaces with foo

>However, Im trying to use a filterset as defined in a file, i.e.
><filtersfile> with entries such as:

>TOKEN1=${TOKEN1value}

>This doesn't work, @TOKEN1@ merely gets replaces with '${TOKEN1value}'
>(literally), and the subsequent replace with the property value does not
>happen. I didn't expect this but thought ok, maybe nobody's thought of
>this. (Properties files work fine with in-file replacing, but Filters
>files seem not to)

>I then looked into filterchains, and set up a filterchain composed of:

>      <filterchain>
>        <tokenfilter>
>          <replaceregex pattern="\@(.*)\@" replace="${\1}" flags="gi"/>
>        </tokenfilter>
>        <expandproperties/>
>      </filterchain>

>This doesn't work either.- the expandproperties gets ignored, despite
>this is what filterchains were invented for..

>I've tried using the recurse param on a filterset, I've tried just about
>everything, and cant get a @TOKEN@ to be replaced with a property value,
>if the filter token comes from a file.

>Any help from someone who has solved this would be great, just about
>tearing my hair out (:-) I have about 50 billion tokens to replace, and
>would prefer them to be in a file rather than build.xml as build.xml is
>not an appropriate place for them. Some of these tokens should be
>replaced with the value of a property at runtime. 

>Ant 1.6.5
>Ant-contrib-1.0b2

>Thanks
>-Geoff




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



Ciao, Jürgen



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