You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by An...@dana.com on 2001/08/23 14:42:43 UTC

Available or If/Unless problem

I built the following build file to narrow down a problem I'm having with
the If/Unless feature.

<project name="java standard library" default="echo" basedir=".">
     <property name="bw.local.present" value="true"/>
     <property name="bw.dev.present" value="false"/>
     <target name="echoLocal" if="${bw.local.present}">
          <echo>BW Local Present</echo>
     </target>
     <target name="echoDev" if="${bw.dev.present}">
          <echo>BW Dev Present</echo>
     </target>
     <target name="echo" depends="echoLocal,echoDev"/>
</project>


I would expect the target 'echoLocal' to print out but not 'echoDev'.  In
the following excerpt from a debug output, the properties seem to be set
correctly, but the "If" check still says that it is going to skip running
the target because the property is not set.

**************************************************
Project base dir set to: C:\IT\Dev\JavaLib
   +Task: property
Setting project property: bw.local.present -> true
   +Task: property
Setting project property: bw.dev.present -> false
 +Target: echoLocal
   +Task: echo
 +Target: echoDev
   +Task: echo
 +Target: echo
Build sequence for target `echo' is [echoLocal, echoDev, echo]
Complete build sequence is [echoLocal, echoDev, echo]

echoLocal:
Skipped because property '${bw.local.present}' not set.

echoDev:
Skipped because property '${bw.dev.present}' not set.

echo:

BUILD SUCCESSFUL

Total time: 2 seconds
*************************************************


Thanks in advance for help and I've attached a copy of the full debug
output in case it's helpful.
(See attached file: out.txt)


Andy

****************************
Andrew Goodnough
Dana Commercial Credit
Programmer
(419) 891-2065

Re: Available or If/Unless problem

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 23 Aug 2001, Andrew Goodnough <An...@dana.com>
wrote:

> I built the following build file to narrow down a problem I'm having
> with the If/Unless feature.

(1) if expects the name of the property, not the dereferenced value,
you are checking the properties true and false - both do not exist, so
no target will be executed.

(2) if/unless tests for the existence of a property, not for its
value. In your case, both properties are set and consequently both
targets will be executed if you remove the ${} dereference.

Stefan