ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "N. J. O'Neill" <njone...@llnl.gov>
Subject RE: environment variables
Date Fri, 13 Apr 2001 21:28:49 GMT
As always, it's obvious once you see how to do it -- just use the os.name 
system property in the name of a new Ant property:

   <property name="is.${os.name}" value="true"/>

   <target name="sunStuff" if="is.SunOS">
      :
      :
   </target>


--Neil





At 06:19 PM 4/12/01, you wrote:
>I haven't seen an obvious way to do this sort of thing yet.
>
>I haven't tested the sample below, but I think something along these lines
>would work, if you can't find anything more direct.
>
>...
>
><property environment="env"/>
>
><!-- Create a file with the same name as the OS. -->
><echo message="os" file="${env.os.name}.tmp"/>
>
><!-- Set a property, depending on which OS file is present. -->
><available file="SunOS.tmp" property="sun.os"/>
><available file="Windows_NT.tmp" property="windows.nt"/>
><delete file="${env.os.name}.tmp"/>
>
><!-- Now execute targets depending on the property that was set. -->
><target name="sunos.target" if="sun.os">
>     <!-- do something -->
></target>
>
><target name="windowsnt.target" if="windows.nt">
>     <!-- do something -->
></target>
>
>...
>
>-----Original Message-----
>From: N. J. O'Neill [mailto:njoneill@llnl.gov]
>Sent: Thursday, April 12, 2001 10:41 PM
>To: ant-user@jakarta.apache.org
>Subject: RE: environment variables
>
>
>
>But there doesn't seem to be a way to control execution of a target based
>on the value of a property.  For example, I want to have a target that only
>executes if the OS is "SunOS".  I can't see a way to use either the
>'property' task or the 'available' task to set a property based on whether
>the value of ${os.name} is "SunOS" or not.
>
>


Mime
View raw message