You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rob Wilson <ne...@gmail.com> on 2007/11/07 22:01:18 UTC
Can I replace some text in a fileset - using values from properties?
Say I have a file with a few files, and would like to inject some
values via ant properties, i.e. company.txt contains
"Thank you for trying the product from ${companyName}."
Is there an Ant task that given a property entry of
<property name="company.txt" value="woof.com"/>
Will result in company.txt containing
"Thank you for trying the product from woof.com"
Thanks,
Rob.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Can I replace some text in a fileset - using values from properties?
Posted by Peter Reilly <pe...@gmail.com>.
The best way is *not* to do in place replacement.
Have the templates in a source directory and the
results in a target directory, then just use
the copy task with an expandproperties filter in a filterchain:
<project name="expand" default="build">
<property name="companyName" value="woof.com"/>
<target name="build">
<mkdir dir="target"/>
<copy todir="target">
<fileset dir="src" includes="**/*.txt"/>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
</target>
<target name="clean">
<delete dir="target"/>
</target>
</project>
Peter.
On 11/7/07, Rob Wilson <ne...@gmail.com> wrote:
> Say I have a file with a few files, and would like to inject some
> values via ant properties, i.e. company.txt contains
>
> "Thank you for trying the product from ${companyName}."
>
> Is there an Ant task that given a property entry of
>
> <property name="company.txt" value="woof.com"/>
>
> Will result in company.txt containing
>
> "Thank you for trying the product from woof.com"
>
> Thanks,
> Rob.
>
> ---------------------------------------------------------------------
> 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