ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: is a property defined?
Date Sun, 29 Jun 2008 17:55:11 GMT
This is Nant or Ant? If this is Ant, you'd do it this way:

<if>
   <equals arg1="${var}" arg2=""/>
   <then>
         <echo>blah, blah, blah</echo>
   </then>
   <else>  <!-- OPTIONAL-->
        <echo>Yadda, Yadda, Yadda</echo>
   </else>
</if>

If you want to do not equals, you do this:

<if>
    <not>
       <equals arg1="${var}" arg2=""/>
    </not>
    <then>
       <echo message="Blah, blah, blah"/>
    </then>
<if>


Take a look at the <condition> task's conditions at
<http://ant.apache.org/manual/CoreTasks/conditions.html>

--
David Weintraub
qazwart@gmail.com


On Sun, Jun 29, 2008 at 5:19 AM, Guy Catz <Guy.catz@waves.com> wrote:
> How can I tell if a property is defined?
>
> I've tried <if> from contrib like this - if .. ${var} = "" ...
> That's fine for properties which was set to "", but not for properties who haven't set
at all.
>
> Next, I've tried <length string="${var}" property="length.var"...
> and then <if> ${length.var}="0", but I always get length.var = 6 because it didn't
open the ${var}, which is 6 chars.
>
> Please advise.
>
> Thanks,
>    Guy.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message