ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <rhi...@sympatico.ca>
Subject Re: Properties set within conditions
Date Tue, 12 Oct 2004 17:35:42 GMT
Thanks, Dominique! I'm one of those people who doesn't follow verbal
descriptions nearly as well as a real example so your example - and
Vadim's - are very helpful in understanding what I am doing wrong.

Rhino

----- Original Message ----- 
From: "Dominique Devienne" <DDevienne@lgc.com>
To: "Ant Users List" <user@ant.apache.org>
Sent: Tuesday, October 12, 2004 12:39 PM
Subject: RE: Properties set within conditions


> From: Rhino [mailto:rhino1@sympatico.ca]
>
> Can you tell me what search words to use for finding some of these
many
> examples that you say are in the archives? I spent considerable time
> looking
> in the archive already, using search terms like 'conditional property'
and
> so forth but none of them revealed a clear example that resembled what
I
> am trying to do.

Here's an old example I grabbed from a build file of a friend.

  <!-- Set platform-specific properties -->
  <target name="set_platform_properties"
          depends="set_platform,
                   set_properties_windows,
                   set_properties_linux,
                   set_properties_solaris"/>
  <target name="set_platform">
    <condition property="os.is.windows">
      <os family="windows"/>
    </condition>
    <condition property="os.is.linux">
      <os name="Linux"/>
    </condition>
    <condition property="os.is.solaris">
      <os name="SunOS"/>
    </condition>
  </target>
  <target name="set_properties_windows" if="os.is.windows">
    <property name="platform" value="win32"/>
    <property name="can.jni" value="true"/>
  </target>
  <target name="set_properties_linux" if="os.is.linux">
    <property name="platform" value="linux"/>
    <property name="can.jni" value="true"/>
  </target>
  <target name="set_properties_solaris" if="os.is.solaris">
    <property name="platform" value="solaris"/>
    <property name="can.jni" value="true"/>
  </target>

I personally have my own version of <property> that supports
different builtin conditions, so I rarely need the technique
anymore ;-) --DD

    <bm:property name="host">
      <value osFamily="windows" value="${env.COMPUTERNAME}" />
      <value osFamily="unix"    value="${env.HOSTNAME}" />
    </bm:property>

    <bm:property name="cvs"> <!-- Use TortoiseCVS' cvs.exe on Windows
-->
      <value os="win32" location="C:\Program Files\TortoiseCVS\cvs.exe"
/>
      <default value="cvs" />
    </bm:property>


---------------------------------------------------------------------
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