ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject RE: myenv property question....
Date Thu, 02 Aug 2001 02:09:33 GMT
Try this

<project name="test" default="main">

  <target name="main">
    <property environment="myenv"/>
    <property name="myenv.CVS_RSH" value="default"/>
    <echo message="CVS_RSH is ${myenv.CVS_RSH}"/>
  </target>
</project>

This is set myenv.CVS_RSH to the CVS_RSH environment variable if it is set
and to default if it is not

Conor


> -----Original Message-----
> From: Phil Beiler [mailto:phil_beiler@fanniemae.com]
> Sent: Thursday, 2 August 2001 11:50 AM
> To: ant-user@jakarta.apache.org
> Subject: myenv property question....
>
>
> Why does ANT do this? How should I do this?
>
> 1. I am using the myenv.xxxxx approach to getting environment variables. I
> wanted to feed conditionally set environment variables to some
> jUnit tests..
> 2. If the variable is NOT set, it puts the myenv.xxxxxx as the
> value of the
> property, rather than setting it to null or blank.
> 3. Why would the code, ProjectHelper.java, replaceProperties
> method set the
> value to property is was looking for when it is not found in the
> environment?
>
> Obviously, this is not how I should be doing this... for example...
>
> 1. if the OVERRIDE_LOG4J environment variable is not set, use the default
> properties file
> 2. if the OVERRIDE_LOG4J environment variable is set, use that properties
> files to initialize log4j
>
> Simple, but I cannot cleanly determine if the variable is set or not.
>
> Thanks for any help.
>
> Phil
>
> --------------- Output from ant ----------------------------------
>
> Ant version 1.3 compiled on March 2 2001
>
> Searching for build.test.xml ...
> Detected Java Version: 1.3
> Detected OS: Windows NT
> Project base dir set to: C:\home\me\UnitTest
>  [property] Loading Environment myenv.
> Property ${myenv.TEST_SET} has not been set         !!!!!!!!!!!!!!
> Build sequence for target `me' is [me]
> Complete build sequence is [me]
>
> me:
>      [echo]
>       Env Variable ${myenv.TEST_SET}
>
>
> BUILD SUCCESSFUL
>
> Total time: 1 second
>
>
> --------------------------------- SIMPLE XML FILE --------------------
>
>
> <?xml version="1.0"?>
>
> <project name="test" default="me" basedir=".">
>
>   <property name="envProps" environment="myenv" />
>   <property name="env.variable"  value="${myenv.TEST_SET}"/>
>
>   <target name="me">
>      <echo>
>       Env Variable ${env.variable}
>      </echo>
>   </target>
> </project>
>
>
>
>
>
>


Mime
View raw message