ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <>
Subject Re: how to echo out the os and os family
Date Mon, 02 Jun 2003 12:02:03 GMT
In ant, when you echo an unset property, such as myproperty, ant echoes
This is maybe an annoying feature, but this is the way it works.
Maybe there are in the properties which ant defines automatically already
some properties which suit you.
Add <echoproperties/> in you build file to see **All*** the properties
currently set.
If you want a property to be set always, here an example

<condition property="isDos" value="true">
    <os family="dos"/>
<!-- this will only applied if isDos has not been set previously -->
<property name="isDos" value="false"/>
<echo message="dos is ${isDos}"/>

Properties in ant are immutable. Once you have set them once, they do not
change. So the trick is to give default values to properties *** after ***
having used for instance condition, which will only set the value of a
property under ... the conditions of your choice.



----- Original Message -----
From: "Ray Tayek" <>
To: <>
Sent: Monday, June 02, 2003 12:51 PM
Subject: how to echo out the os and os family

> hi, trying to get a project to work on a few platforms (and in netbeans
> with junit). having trouble getting the os and os family to echo out. i
> get the following ok (see below). but i can not seem to echo out the os or
> os family, so i get a bunch of funnty printouts when i run this as only
> has a value other than itself (ie. isDos=${isDis} prints out on unix,
> isUnit=true comes out on unix). how do i get rid of this?
> thanks
>          <target name="init">
>                  <tstamp/>
>                  <property environment="env"/>
>                  <condition property="isDos"> <os family="dos"/>
>                  <echo message="isDos=${isDos}"/>
>                  <condition property="isUnix"> <os family="unix"/>
>                  <echo message="isUnix=${isUnix}"/>
>                  <condition property="isMac"> <os family="mac"/>
>                  <echo message="isMac=${isMac}"/>
>                  <condition property="isMacButNotMacOsX">
>                          <and>
>                                  <os family="mac" />
>                                  <not><os family="unix" /></not>
>                          </and>
>                  </condition>
>                  <echo message="isMacButNotMacOsX=${isMacButNotMacOsX}"/>
>                  <echo message="${os}"/>
>                  <echo message="${os family}"/>
>                  <condition property="tmp" value="${env.TMP}"> <istrue
> value="${isDos}"/> </condition>
>                  <condition property="tmp" value="/tmp"> <istrue
> value="${isUnix}"/> </condition>
>                  <!--more needed for mac cases-->
>                  <echo message="tmp=${tmp}"/>
>                  <condition property="junitPath" value="../junit3.7"> <os
> family="unix"/> </condition>
>                  <condition property="junitPath" value="../junit3.8.1">
> family="dos"/> </condition>
>                  <!--more needed for mac cases-->
>                  <echo message="junitPath=${junitPath}"/>
>          </target>
> ---
> ray tayek actively seeking mentoring or telecommuting
> vice chair orange county java users group
> hate spam?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message