ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sony Antony <sony.ant...@gmail.com>
Subject Re: Reusing property values in a properties file
Date Sun, 11 Jul 2010 14:52:48 GMT
Beware of this bug,https://issues.apache.org/bugzilla/show_bug.cgi?id=44226

If you have a property line like this in your properties file used for filter..
XXX=jhkhk
YYY=@XXX@ukjljljl@XXX@
( @XXX@ appearing multiple times above )

... you will get in trouble

 that has been fixed in ant 1.8, I think


Also note that although properties are not mutable, substitution
properties  can be changed ( last one wins )
     <filterset begintoken="@" endtoken="#">
            <filter token="TOK1" value="HUHU"/>
            <filter token="TOK1" value="HUHUXXX"/>
            <filtersfile file="props"/>
         </filterset>

In this case, value from TOK1 will be taken from the file props ( If
it is defined there ).
And if the file has multiple definitions for TOK1, last one will win

--sony




On Sun, Jul 11, 2010 at 2:55 AM, David Weintraub <qazwart@gmail.com> wrote:
> It would be nice if you posted some code explaining how all of this works.
>
> You cannot change a property value, but of course, you can reuse it as
> many times as you want to set other properties. That is, if you define
> a property user, it could be used to set the other properties. All you
> have to do is surround the name with curly braces and prepend it with
> a dollar sign:
>
> USER_NAME=batuser
> DB_USERNAME=${USER_NAME}
> UNIX_USERNAME=${USER_NAME}
>
> I'm assuming you're using a filter task. Yes, your filter file should
> look like this:
>
> USER_NAME=@USER_NAME@
> DB_USERNAME=${USER_NAME}
> UNIX_USERNAME=${USER_NAME}
>
> The filter will change the first line to the correct string value. Or,
> you can do it like this:
>
> USER_NAME=@USER_NAME@
> DB_USERNAME=@USER_NAME@
> UNIX_USERNAME=@USER_NAME@
>
> The filter will replace all instances.
>
> On Sat, Jul 10, 2010 at 9:38 PM, anindya.mukherjee
> <anindya.jobs@gmail.com> wrote:
>>
>> I am using ant in my project as follows. I have templates of all environment
>> files in our application.
>> These templates have properties with placeholders in them like ->
>> DB_SERVER=@DB_SERVER@
>> For each environment we have a properties file. Like for dev we have
>> dev.properties. This contains the actual value of the property like ->
>> DB_SERVER=LNDB241
>> We call ant like this -> ant create -Denv=dev
>> The ant build file has this create task which uses the property values from
>> the properties file to fill in the templates.
>>
>> Now the question is , there are several properties that I reuse in the
>> properties file. Like the directory name . Is there any way I can reuse the
>> properties in the properties file like ( I am doing ant build in windows
>> boxes ) ->
>>
>> In dev.properties -->
>>
>> USER_NAME=batuser
>> DB_USERNAME=$USER_NAME}
>> UNIX_USERNAME=$USER_NAME}
>>
>> --
>> View this message in context: http://old.nabble.com/Reusing-property-values-in-a-properties-file-tp29129304p29129304.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
>>
>>
>
>
>
> --
> David Weintraub
> qazwart@gmail.com
>
> ---------------------------------------------------------------------
> 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