You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ninju Bohra <ni...@yahoo.com> on 2005/04/20 16:40:43 UTC

Re: Using ant properties in file -- Success

The reason that I can't use
@@path_to_main_properties@@=@@deploy_dir@@\main.properties

is the same reason that my original approach wouldn't
work... the <replace> task does not examine/process
the contents of the filterFile.

But going off of what you alluded to, I did come up
with a two-pass approach...

My filterFile looks like:
# Properties to be replaced in the \WEB-INF\web.xml
file
@@path_to_ws_prop@@=${deploy.dir}/WSProp.xml
# Properties to replaced in the smokeTest.xml file
@@compare_output_dir@@=c:/ccbuild/workarea/${project.name}/integration_tests

First, I copy the filterFile (called
replacements.properties in my case) to temp file
(called adjusted_replacements.properties

Then I executed a series of simple replacements in the
adjusted_replacements.properties file, like:
   <replace file="adjusted_replacements.properties"
token="$${deploy.dir}" value="${deploy.dir}"/>
   <replace file="adjusted_replacements.properties"
token="$${project.name}" value="${project.name}"/>

Note the double $$'s in the "token" property -- to
prevent evaluation of the ${property}

And voila! the ${deploy.dir} in the
replacements.properties has been changed to
c:/Projects/MyDeployDir in the
adjusted_replacements.properties file

I then used the adjusted_replacements.properties as
the replaceFilterFile and do <replace>'s on the final
file.

It would have been nice if the <replace> task
supported the ability to pre-process the
replaceFilterFile, but oh well...

Thanx,

Ninju

--- James Abley <ja...@volantis.com> wrote:
> On Wed, 2005-04-20 at 03:40, Ninju Bohra wrote:
> > So anybody have any guidance on whether or not
> > ${property.name} are resolved in <replace> filter
> > file?
> > 
> > 
> > --- Ninju Bohra <ni...@yahoo.com> wrote:
> > > Hello all,
> > > 
> > > Just want to make sure that ANT 1.6.2 can NOT do
> the
> > > following (otherwise I am doing something
> wrong...
> > > which could never be :-))
> > > 
> > > Wanting to replace a bunch of values in a file,
> so I
> > > created a replaceFilterFile containing all the
> > > token=value entries and using the <replace> task
> I
> > > am
> > > able to search/replaces all the "tokens" and put
> the
> > > "value" in there place...
> > > 
> > > The problem is that now we need have the "value"
> > > portion be dependent on a property value (i.e.
> in
> > > the
> > > file we need the following
> > >
> >
>
@@path_to_main_properties@@=${deploy.dir}\main.properties
> > > 
> 
> I'm not that familiar with that task, but can you
> explain why you can't
> use
> 
>
@@path_to_main_properties@@=@@deploy_dir@@\main.properties
> 
> I think that it _won't_ work because you're using
> the replacefilterfile
> attribute, but just wanted to confirm my
> understanding of how it should
> work.
> 
> If that won't work, then maybe use two invocations
> of the replace task -
> the first one creates a temporary file to replace
> @@deploy_dir@@, then
> the second one replaces @@path_to_main_properties@@?
> 
> Cheers,
> 
> James
> 
> > > When I run the <replace> task the above data the
> > > property ${deploy.dir} is NOT replaced.
> > > 
> > > Am I doing anything wrong...
> > > 
> > > Thanx,
> > > 
> > > Ninju
> > > 
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > > protection around 
> > > http://mail.yahoo.com
> > > 
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail:
> > > user-help@ant.apache.org
> > > 
> > > 
> > 
> > 
> > 		
> > __________________________________ 
> > Do you Yahoo!? 
> > Yahoo! Mail - Find what you need with new enhanced
> search. 
> > http://info.mail.yahoo.com/mail_250
> > 
> >
>
---------------------------------------------------------------------
> > 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
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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