You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by neubyr <ne...@gmail.com> on 2011/03/22 16:29:44 UTC

load properties based on deployment environment

Hi,

I want to set some deployment specific string replacements in a
project. For example, the project contains values like
{{{
	connectionurl = "http://localhost"
	connectionport = "12345"
}}}

These values need to be changed based on deployment environment
($deployenv) - dev, qa, or prod. Right now I am using 'if' for setting
these properties, but I am wondering if I can use property and regex
tasks. For example define properties in a deploy.properties like:
{{{
	dev.connectionurl="http\://dev.example.com"
	dev.connectionport="12345"
	test.connectionurl="http\://test.example.com"
	test.connectionport="23456"
	prod.connectionurl="http\://prod.example.com"
	prod.connectionport="34567"
}}}
... and then replace values based on $deployenv.connectionurl and
$deployenv.connectionport.

Any pointers on doing this will be really helpful. Any alternative
approaches or suggestion would be helpful too.

--
thanks,
neubyr.

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


Re: load properties based on deployment environment

Posted by neubyr <ne...@gmail.com>.
Thanks for sharing the link. I am loading properties using
${deployenv}.deploy.properties file now.

One of the issue I am having right now is with replaceregexp task. Is
there any way to expand property in replace attribute  of
replaceregexp task?

{{{
<replaceregexp file="${projectname}-${ver}/sites/config.php"
                        match="\$connectionurl = (.*)"
                        replace="$connectionurl = ${connectionurl}" />
}}}

Any other task that I can use? I have looked at replace task, but
there is no guarantee that developers will check in with specific
token values and hence I am trying to use regexp here. Any help?

--
thanks,
neuby.r

On Tue, Mar 22, 2011 at 11:36 AM, Dominique Devienne
<dd...@gmail.com> wrote:
> On Tue, Mar 22, 2011 at 10:29 AM, neubyr <ne...@gmail.com> wrote:
>> I want to set some deployment specific string replacements in a
>> project. For example, the project contains values like
>> {{{
>>        connectionurl = "http://localhost"
>>        connectionport = "12345"
>> }}}
>>
>> These values need to be changed based on deployment environment
>> ($deployenv) - dev, qa, or prod. Right now I am using 'if' for setting
>> these properties, but I am wondering if I can use property and regex
>> tasks. For example define properties in a deploy.properties like:
>> {{{
>>        dev.connectionurl="http\://dev.example.com"
>>        dev.connectionport="12345"
>>        test.connectionurl="http\://test.example.com"
>>        test.connectionport="23456"
>>        prod.connectionurl="http\://prod.example.com"
>>        prod.connectionport="34567"
>> }}}
>> ... and then replace values based on $deployenv.connectionurl and
>> $deployenv.connectionport.
>>
>> Any pointers on doing this will be really helpful. Any alternative
>> approaches or suggestion would be helpful too.
>
> See http://marc.info/?l=ant-user&m=129599356521220&w=1 and it's
> associated thread. --DD
>
> ---------------------------------------------------------------------
> 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


Re: load properties based on deployment environment

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Mar 22, 2011 at 10:29 AM, neubyr <ne...@gmail.com> wrote:
> I want to set some deployment specific string replacements in a
> project. For example, the project contains values like
> {{{
>        connectionurl = "http://localhost"
>        connectionport = "12345"
> }}}
>
> These values need to be changed based on deployment environment
> ($deployenv) - dev, qa, or prod. Right now I am using 'if' for setting
> these properties, but I am wondering if I can use property and regex
> tasks. For example define properties in a deploy.properties like:
> {{{
>        dev.connectionurl="http\://dev.example.com"
>        dev.connectionport="12345"
>        test.connectionurl="http\://test.example.com"
>        test.connectionport="23456"
>        prod.connectionurl="http\://prod.example.com"
>        prod.connectionport="34567"
> }}}
> ... and then replace values based on $deployenv.connectionurl and
> $deployenv.connectionport.
>
> Any pointers on doing this will be really helpful. Any alternative
> approaches or suggestion would be helpful too.

See http://marc.info/?l=ant-user&m=129599356521220&w=1 and it's
associated thread. --DD

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