You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by wizshah <sh...@gmail.com> on 2008/07/09 12:29:22 UTC

overwriting property specified in different files.

I have two following lines added to my build.xml.

 	
1. <property file="${env.DEVHOME}/config/config.properties"/>
	
2. <property
file="${env.DEVHOME}/usr/home/${env.projectname}/config.properties"/>

It can be seen that I have two config.properties being loaded. Thats runs
fine. All properties are loaded. But here the problem is that if I have the
same property in the second file it does not overwrite the old one. 
for instance I have a temp variable set like temp=temp in the first config
i.e. config/config.properties

where as I want to over write it in the second config i.e.
${env.projectname}/config.properties like temp=xyz

But ant does not overwrite it. Can any one help me out how I can achieve
this?

-- 
View this message in context: http://www.nabble.com/overwriting-property-specified-in-different-files.-tp18358563p18358563.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: overwriting property specified in different files.

Posted by wizshah <sh...@gmail.com>.
Yes that makes sense.

The problem would then be that if the property is empty in the first file
the second would not get its thing in the zone. 

All that said I think I can workout something that doesn't allow empty
fields to be written at all.

And thanks for the clarification.

Regards,
-- wiz



André Pilz wrote:
> 
> Hello,
> 
> that is standard behaviour for ant. The first property definition wins. 
> A simple solution for this example is to load the second property file 
> first.
> 
> Also see the <variable> Task in ant-contrib, but I never needed it.
> 
> Cheers,
> Andre
> 
> wizshah schrieb:
>> I have two following lines added to my build.xml.
>> 
>>  	
>> 1. <property file="${env.DEVHOME}/config/config.properties"/>
>> 	
>> 2. <property
>> file="${env.DEVHOME}/usr/home/${env.projectname}/config.properties"/>
>> 
>> It can be seen that I have two config.properties being loaded. Thats runs
>> fine. All properties are loaded. But here the problem is that if I have
>> the
>> same property in the second file it does not overwrite the old one. 
>> for instance I have a temp variable set like temp=temp in the first
>> config
>> i.e. config/config.properties
>> 
>> where as I want to over write it in the second config i.e.
>> ${env.projectname}/config.properties like temp=xyz
>> 
>> But ant does not overwrite it. Can any one help me out how I can achieve
>> this?
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/overwriting-property-specified-in-different-files.-tp18358563p18363280.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: overwriting property specified in different files.

Posted by Tom Drynda <ta...@pineridge.co.uk>.
André Pilz <an...@pcvisit.de> wrote:
> ...
> that is standard behaviour for ant. The first property definition wins. 
> A simple solution for this example is to load the second property file 
> first.
> ...

That's exactly how we do it.

We have a default configuration held in a properties file.

Users (including the Test/UAT/CruiseControl/Staging/Production/etc users) each have a properties file which contains a subset of the default configuration - i.e. just the parts they need to change in order to develop/test/debug on their own systems/workstations/sand-boxes.

When Ant is run, first the User's properties file is loaded. Next, the default properties file is loaded.

This has the following advantages (in no particular order):
    * User?s properties are the only ones that need to be customised for a particular user?s instance.
    * Minimal configuation for a new user
    * New properties added during development can be moved to default properties once they have been tested. Default properties are then propagated out without each user having to change their own properties file every time something changes.

The bottom line is that a user doesn't have to make sure that their properties file contains a full set of properties all of the time. If a new property is added during development, once it is propagated in to the default properties file and checked in to the repository (along with the associated code, one assumes) it is available for everyone after the next update from the repository.

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


Re: overwriting property specified in different files.

Posted by André Pilz <an...@pcvisit.de>.
Hello,

that is standard behaviour for ant. The first property definition wins. 
A simple solution for this example is to load the second property file 
first.

Also see the <variable> Task in ant-contrib, but I never needed it.

Cheers,
Andre

wizshah schrieb:
> I have two following lines added to my build.xml.
> 
>  	
> 1. <property file="${env.DEVHOME}/config/config.properties"/>
> 	
> 2. <property
> file="${env.DEVHOME}/usr/home/${env.projectname}/config.properties"/>
> 
> It can be seen that I have two config.properties being loaded. Thats runs
> fine. All properties are loaded. But here the problem is that if I have the
> same property in the second file it does not overwrite the old one. 
> for instance I have a temp variable set like temp=temp in the first config
> i.e. config/config.properties
> 
> where as I want to over write it in the second config i.e.
> ${env.projectname}/config.properties like temp=xyz
> 
> But ant does not overwrite it. Can any one help me out how I can achieve
> this?
> 

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