ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <levylamb...@tiscali-dsl.de>
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
${myproperty}.
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"/>
</condition>
<!-- 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.

Cheers

Antoine

----- Original Message -----
From: "Ray Tayek" <rtayek@attbi.com>
To: <user@ant.apache.org>
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
can
> 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
one
> has a value other than itself (ie. isDos=${isDis} prints out on unix,
while
> 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"/>
</condition>
>                  <echo message="isDos=${isDos}"/>
>                  <condition property="isUnix"> <os family="unix"/>
</condition>
>                  <echo message="isUnix=${isUnix}"/>
>                  <condition property="isMac"> <os family="mac"/>
</condition>
>                  <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">
<os
> family="dos"/> </condition>
>                  <!--more needed for mac cases-->
>                  <echo message="junitPath=${junitPath}"/>
>          </target>
>
> ---
> ray tayek http://tayek.com/ actively seeking mentoring or telecommuting
work
> vice chair orange county java users group http://www.ocjug.org/
> hate spam? http://samspade.org/ssw/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



Mime
View raw message