ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stan Rosenberg" <ale...@mindspring.com>
Subject RE: Environment Property
Date Sun, 27 Jan 2002 09:34:50 GMT
Viraf,

You are absolutely right about the behavior of Ant when the environment
variable is not found in the project. Instead of testing for an empty
string, you need to test for ${env.VARNAME}
However, I think that it would be more intuitive if the return value were an
empty string. Why don't you send a patch to the ant-dev list? As far as the
"." business goes, I am not clear about this notion. If you find out,
please, let me know:)

Stan

-----Original Message-----
From: Viraf Bankwalla [mailto:viraf_bankwalla@yahoo.com]
Sent: Sunday, January 27, 2002 1:41 AM
To: Ant Users List
Subject: RE: Environment Property


Stan,

The following is from my ANT file.

<target name="init">
  <property environment="env" />
  <property name="isdefined" value="${env.VARNAME}"/>


  <condition property="isdefined" value="default">
    <equals arg1="${server}" arg2="" />
  </condition>

  <echo message="${server}" />
</target>

When ANT 1.4.1 is run the following is displayed

${env.VARNAME}

I would have expected an empty string to be displayed.
 I am basically trying to set up properties in init
based on environment variables.

What I am trying to do is set up the build environment
based on OS environment variables.  I get the value of
the variable and invoke <antcall target="${isdefined}"
/>

This way I can have handlers that are specific to the
build.  The next problem that I ran into is that the
called task appears to be unable to pass back
properties to the properties.

What does the "." at the end of the environment
variable indicate ?  It was unclear to me from the
docs.

Thanks.

- viraf


--- Stan Rosenberg <alesta@mindspring.com> wrote:
> Viraf,
>
> What version of Ant are you running? Please, make
> sure that the environment
> variable you are
> trying to 'echo' is really contained in the
> environment and maybe remove the
> dot in <property environment="env." /> so that it
> reads <property
> environment="env" />
>
> I tested this on Ant 1.4.1, and it works fine.
>
> Cheers,
>
> Stan
>
> -----Original Message-----
> From: Viraf Bankwalla
> [mailto:viraf_bankwalla@yahoo.com]
> Sent: Sunday, January 27, 2002 12:22 AM
> To: ant-user@jakarta.apache.org
> Subject: Environment Property
>
>
> Hi,
>
> How do I test for the existence of an environment
> variable ?  How do I take an action if a the
> variable
> is defined ?
>
> I assumed that:
>
>   <property environment="env." />
>   <property name="isdefined" value="${env.VARNAME}"
> />
>   <echo message="isdefined: ${isdefined}" />
>
> would disply
>
>    isdefined:
>
> however it displays
>
>    isdefined: ${env.VARNAME}
>
> If this is not the desired behaviour, the fix lies
> in
> ProjectHelper::replaceProperties.
>
>     fragment = (keys.containsKey(propertyName)) ?
> (String) keys.get(propertyName)
>        : "${" + propertyName + "}";
>
>
> Thanks.
>
> - viraf
>
> __________________________________________________
> Do You Yahoo!?
> Great stuff seeking new owners in Yahoo! Auctions!
> http://auctions.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:ant-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:ant-user-help@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

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


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


Mime
View raw message