ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "EJ Ciramella" <ejcirame...@upromise.com>
Subject RE: Loading interdependent properties files WAS RE: Trying (and failing) to build the nightly snapshot
Date Mon, 04 Aug 2008 15:05:21 GMT
How does ant choose which properties take precedence?

So say db.port is defined in three properties files (default.properties,
stack.properties and machine.properties).

Generally, we'd load them in this order:

Machine.properties
Stack.properties
Default.properties

Developers re-use default.properties, the stack generally uses a certain
port and finally, a particular machine (say a secondary machine) would
use a third variation.

How would that loadproperties task choose which one takes precedence?

-----Original Message-----
From: Matt Benson [mailto:gudnabrsam@yahoo.com] 
Sent: Monday, August 04, 2008 10:40 AM
To: Ant Developers List
Subject: Loading interdependent properties files WAS RE: Trying (and
failing) to build the nightly snapshot


--- EJ Ciramella <ejciramella@upromise.com> wrote:

> Right - in an ideal world, sure. 
> 
> We're using ant for deployments and the first file
> is the MOST specific
> file, the secondary one is the more generic file.
> 
> So, in a nutshell, we can't alter the order of the
> property files.
> 
> What is interesting though is if all the properties
> are in the SAME
> file, there's no problem (as all the expansion can
> happen at once).  Can
> I do something with concat?  <propertyfileset> or
> something?
> 
> If concat could do something like, "first found
> takes precedence but in
> general add all the properties" that would be
> perfect...
> 

In Ant 1.7.x, if you can "bundle" all your files, you
should be able to <loadproperties><concat><!--insert
bundle here--></concat></loadproperties> them.

HTH,
Matt

> -----Original Message-----
> From: Steve Loughran [mailto:stevel@apache.org] 
> Sent: Monday, August 04, 2008 9:48 AM
> To: Ant Developers List
> Subject: Re: Trying (and failing) to build the
> nightly snapshot
> 
> EJ Ciramella wrote:
> > I think I misunderstood this particular bug.  It
> appears to be a
> problem
> > with $${someprop} versus loading two property
> files and the first one
> > containing a ${property} that is set in the second
> one loaded.
> > 
> > To be explicit, if you have two property files,
> a.properties and
> > b.properties, in the first one loaded you have a
> ${property} that is
> set
> > in b.properties, ant leaves it as ${}.
> > 
> > a.properties:
> > 
> > foo=bar
> > 
> > coolprop=${foo}:${from.b.properties}
> > 
> > 
> > 
> > 
> > 
> > b.properties:
> > 
> > from.b.properties=awesome
> > 
> > 
> > 
> > 
> > build.xml:
> > 
> > <project default="go">
> >     <target name="go" >
> > 	<property file="a.properties" />   
> >       <property file="b.properties" />
> >         <echo>This is a problem:
> ${coolprop}</echo>
> >     </target>
> > </project>
> > 
> > You'll see this:
> > 
> > This is a problem: bar:${from.b.properties}
> 
> That's because property expansion takes place when
> the properties files 
> are loaded. If you want properties from
> b.properties, load it before 
> a.properties
> 
> 
> 
> 
> -- 
> Steve Loughran                 
> http://www.1060.org/blogxter/publish/5
> Author: Ant in Action           http://antbook.org/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
> 
> 



      

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


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


Mime
View raw message