ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: AW: AW: How to set properties when property is set
Date Tue, 23 May 2006 12:21:11 GMT
Depends on your requirement .....

1. Load (additionally) different sets if resources are available

<available property="pf1" value="propfile-1.properties" file="file-to-test-1"/>
<property name="pf1" value="file-does-not-exist"/>
<property file="${pf1}"/>

<available property="pf2" value="propfile-2.properties" file="file-to-test-2"/>
<property name="pf2" value="file-does-not-exist"/>
<property file="${pf2}"/>
...

"file-does-not-exist" is an empty properties file, so loading that doesnt throw an exception.

Could be made easier....

<macrodef name="loadprops">
    <attribute name="file"/>
    <attribute name="propfile"/>
    <sequential>
        <available property="p.@{file}" value="@{propfile}" file="@{file}"/>
        <property name="p.@{file}" value="file-does-not-exist"/>
        <property file="${p.@{file}}"/>
    </sequential>        
</macrodef>

<loadprops file="file-to-test-1" propfile="propfile-1.properties"/>
<loadprops file="file-to-test-2" propfile="propfile-2.properties"/>



2. Load different sets according to a properties value

<input property="whichPFile" validargs="dev,test,life"/>
<property file="${whichPFile}.properties"/>




Just my quick thoughts (so no syntax checks .... ;-)


Jan

 

>-----Ursprüngliche Nachricht-----
>Von: Michael Pustovalov [mailto:pustovalov@protei.ru] 
>Gesendet: Dienstag, 23. Mai 2006 13:55
>An: 'Ant Users List'; floess@mindspring.com
>Betreff: RE: AW: AW: How to set properties when property is set
>
>Jan:  your solution is cool :)
>
>But there is one moment - that solution is useful when ONE 
>file must be loaded, if anybody need to load two or more files 
>with properties - I don't see other solutions, than use <if/> 
>or play with <target/>'s ( I hate copy/paste :) )
>
>Anybody here knows solution for loading MANY property files in 
>such situation with ant core tasks(that differs from playing 
>with <target/>'s ) ?
>
>
>----====[]====----
>
>С уважением, Пустовалов Михаил [mailto:pustovalov@protei.ru]
>    RDC Protei
>
>
>
>-----Original Message-----
>From: Scot P. Floess [mailto:floess@mindspring.com]
>Sent: Tuesday, May 23, 2006 3:30 PM
>To: user@ant.apache.org
>Subject: Re: AW: AW: How to set properties when property is set
>
>Jan:
>
>Sorry, I see your point...he could define the properties in a 
>property file and do as you list...  From his email I took it 
>literally - meaning he wanted to set the property values in 
>his build.xml.  Your solution is a very clean and elegant 
>solution - I like it  :) 
>
>
>Jan.Materne@rzf.fin-nrw.de wrote:
>>> The only problem is he stated setting multiple properties...not a 
>>> single one....
>>>     
>>
>> Where is the problem? You can define multiple properties in the 
>> property-file.....
>>
>>
>> Jan
>>
>>
>>   
>>>> <condition property="propfile" value="present.properties"
>>>>       
>> else="absent.properties">
>>   
>>>>     <available file="${gen.dir}"/>
>>>> </condition>
>>>> <property file="${propfile}"/>
>>>>       
>>
>>   
>
>--
>Scot P. Floess
>27 Lake Royale
>Louisburg, NC  27549
>
>252-478-8087 (Home)
>919-754-4592 (Work)
>
>Chief Architect JPlate  http://sourceforge.net/projects/jplate
>Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>
>
>
>---------------------------------------------------------------------
>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


Mime
View raw message