You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Brown, Carlton" <Ca...@BellSouth.com> on 2005/11/09 16:09:00 UTC

Bulk token substitution

Hello,

 

I'm looking to do bulk replacement of tokens in a file.  This is to
replace a perl-based build solution.    I have created the
single-replacement solution in ant, but I am somewhat stumped as to how
to do a bulk substitution.   

 

The following code copies all files named *.src to a new file without
the *.src suffix, replacing APP_HOME with /usr/local/app, as expected:

 

 

<target name="do-macro" depends="check-macro" unless="macro.uptodate">

<echo message="Status of replacement targets is ${macro.uptodate}" /> 

<copy todir="${build.root}" overwrite="true">

               <fileset dir="${src.root}" includes="**/*.src" /> 

               <mapper type="glob" from="*.src" to="*" /> 

<filterset begintoken="@#$%" endtoken="%$#@">

                         <filter token="APP_HOME" value="/usr/local/app"
/> 

            </filterset>

  </copy>

</target>

 

The problem is that we have something like 50 other tokens to replace in
addition to APP_HOME.   I do not want to clutter this build file with
the filter definitions, and I'd like to share these filter definitions
with other build tasks.   I'd like to define the filterset in an
external file, if possible.

 

Can someone get me going in the right direction?   I read the FAQ and
this does not seem to be covered.


*****
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. 162


Re: Bulk token substitution

Posted by Ninju Bohra <ni...@yahoo.com>.
Have you looked that the propertyfile attribute of the <replace> task.  It
allows you define a file (in JAVA property file format) that contains all the
replacements instructions.


--- "Brown, Carlton" <Ca...@BellSouth.com> wrote:

> Hello,
> 
>  
> 
> I'm looking to do bulk replacement of tokens in a file.  This is to
> replace a perl-based build solution.    I have created the
> single-replacement solution in ant, but I am somewhat stumped as to how
> to do a bulk substitution.   
> 
>  
> 
> The following code copies all files named *.src to a new file without
> the *.src suffix, replacing APP_HOME with /usr/local/app, as expected:
> 
>  
> 
>  
> 
> <target name="do-macro" depends="check-macro" unless="macro.uptodate">
> 
> <echo message="Status of replacement targets is ${macro.uptodate}" /> 
> 
> <copy todir="${build.root}" overwrite="true">
> 
>                <fileset dir="${src.root}" includes="**/*.src" /> 
> 
>                <mapper type="glob" from="*.src" to="*" /> 
> 
> <filterset begintoken="@#$%" endtoken="%$#@">
> 
>                          <filter token="APP_HOME" value="/usr/local/app"
> /> 
> 
>             </filterset>
> 
>   </copy>
> 
> </target>
> 
>  
> 
> The problem is that we have something like 50 other tokens to replace in
> addition to APP_HOME.   I do not want to clutter this build file with
> the filter definitions, and I'd like to share these filter definitions
> with other build tasks.   I'd like to define the filterset in an
> external file, if possible.
> 
>  
> 
> Can someone get me going in the right direction?   I read the FAQ and
> this does not seem to be covered.
> 
> 
> *****
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential, proprietary, and/or
> privileged material. Any review, retransmission, dissemination or other use
> of, or taking of any action in reliance upon this information by persons or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from all
> computers. 162
> 
> 






		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

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


Re: Bulk token substitution

Posted by Matt Benson <gu...@yahoo.com>.
Hmm... read
http://ant.apache.org/manual/CoreTypes/filterset.html
specifically the <filtersfile> element of <filterset>.

-Matt

--- "Brown, Carlton" <Ca...@BellSouth.com>
wrote:

> Hello,
> 
>  
> 
> I'm looking to do bulk replacement of tokens in a
> file.  This is to
> replace a perl-based build solution.    I have
> created the
> single-replacement solution in ant, but I am
> somewhat stumped as to how
> to do a bulk substitution.   
> 
>  
> 
> The following code copies all files named *.src to a
> new file without
> the *.src suffix, replacing APP_HOME with
> /usr/local/app, as expected:
> 
>  
> 
>  
> 
> <target name="do-macro" depends="check-macro"
> unless="macro.uptodate">
> 
> <echo message="Status of replacement targets is
> ${macro.uptodate}" /> 
> 
> <copy todir="${build.root}" overwrite="true">
> 
>                <fileset dir="${src.root}"
> includes="**/*.src" /> 
> 
>                <mapper type="glob" from="*.src"
> to="*" /> 
> 
> <filterset begintoken="@#$%" endtoken="%$#@">
> 
>                          <filter token="APP_HOME"
> value="/usr/local/app"
> /> 
> 
>             </filterset>
> 
>   </copy>
> 
> </target>
> 
>  
> 
> The problem is that we have something like 50 other
> tokens to replace in
> addition to APP_HOME.   I do not want to clutter
> this build file with
> the filter definitions, and I'd like to share these
> filter definitions
> with other build tasks.   I'd like to define the
> filterset in an
> external file, if possible.
> 
>  
> 
> Can someone get me going in the right direction?   I
> read the FAQ and
> this does not seem to be covered.
> 
> 
> *****
> The information transmitted is intended only for the
> person or entity to which it is addressed and may
> contain confidential, proprietary, and/or privileged
> material. Any review, retransmission, dissemination
> or other use of, or taking of any action in reliance
> upon this information by persons or entities other
> than the intended recipient is prohibited. If you
> received this in error, please contact the sender
> and delete the material from all computers. 162
> 
> 



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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