You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ray Tayek <rt...@attbi.com> on 2003/06/02 12:51:35 UTC

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/


Re: how to echo out the os and os family

Posted by Ray Tayek <rt...@attbi.com>.
At 02:02 PM 6/2/03 +0200, you wrote:
>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.

yes

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

i will try this.

>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}"/>

aha, good trick!


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

got it!

thanks

>----- Original Message -----
>From: "Ray Tayek" <rt...@attbi.com>
>To: <us...@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/


Re: how to echo out the os and os family

Posted by Antoine Levy-Lambert <le...@tiscali-dsl.de>.
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" <rt...@attbi.com>
To: <us...@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
>
>