ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janu Mohandass <janu.mohand...@in.ibm.com>
Subject Re: AW: Check for Env variables
Date Wed, 23 Mar 2005 08:27:12 GMT




Thanks a lot.  That worked indeed.

I do hv another solution for this.

<project>
      <property environment="env"/>

      <target name="env_default" unless="env.OUTPUT_DIR">
            <property name="output.dir" value="default"/>
      </target>

      <target name="env_check" depends="env_default">
            <property name="output.dir" value="${env.OUTPUT_DIR}"/>
      </target>
</project>

Many Thanks,
Janu.





                                                                           
             Jan.Materne@rzf.f                                             
             in-nrw.de                                                     
                                                                        To 
             03/23/05 11:46            user@ant.apache.org                 
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
             "Ant Users List"          AW: Check for Env variables         
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




<project>
    <property environment="env"/>
    <condition property="output.dir" value="${env.OUTPUT_DIR}">
        <isset property="env.OUTPUT_DIR"/>
    </condition>
    <property name="output.dir" value="default"/>

    <echo>output.dir=${output.dir}</echo>
</project>

1. import the environment variables with prefix "env"
2. if the OUTPUT_DIR was set, the the property output.dir to its value
3. set the output.dir to default, which only works, if not set prior.
   Properties are immutable.
4. Give the output.


c:\temp>ant
Buildfile: build.xml
     [echo] output.dir=default

c:\temp>set OUTPUT_DIR=other

c:\temp>ant
Buildfile: build.xml
     [echo] output.dir=other


Jan



> -----Ursprüngliche Nachricht-----
> Von: Janu Mohandass [mailto:janu.mohandass@in.ibm.com]
> Gesendet am: Mittwoch, 23. März 2005 05:44
> An: Ant Users List
> Betreff: Check for Env variables
>
>
>
>
>
> Hi,
>
> I am newbie in ANT. My requirement is, if the environment
> variable is not
> set , then I want  the output to go to the current directory, else
> the value should be picked up from the environment variable.
> I hv written
> the following piece of code,
>
>       <if>
>                         <equals arg1="${env.BLD_OUTPUT}" arg2=""/>
>                         <then>
>                             <property name="localoutput.java"
> value="."/>
>                         </then>
>                  <else>
>                             <property name="localoutput.java"
> value="${env.BLD_OUTPUT}"/>
>                   </else>
>                   </if>
>
> But what happens is ,  If the environment variable is not
> set, My first
> condition does not get executed, the value of
> localoutput.java is set to ${env.BLD_OUTPUT}.
>
> Waiting for suggestions.
>
> Thanks in advance.
>
> Janu.
>
>
> ---------------------------------------------------------------------
> 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