ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bohnet, Ralph" <>
Subject Using if/unless within a target
Date Wed, 09 Aug 2000 20:37:13 GMT

I am trying to use "if" within a target tag, and the documentation indicates
that if the property is set, the target will be executed.  The small
buildfile below indicates that this is not the case.  When I execute this
buildfile, I would expect to see: "executing test1", instead I don't see any
echo messages.  Likewise, if I replace the "if" with "unless", I see both
echo messages.  

Have I set this up incorrectly?  When I turn on verbose, I see the message
that "string.present" is set to true.
This behavior seems buggy and contrary to the documentation.

I am using the release version 1.1, and have also tried it with last night's
build (08/09) with the same result.

Ralph Bohnet

<project name="testConditions" default="all" >
  <target name="check_for_depend" >
    <available property="string.present" classname="java.lang.String" />
    <available property="not.present" classname="foo" />              

  <target name="test1" depends="check_for_depend" if="${string.present}">
    <echo message="executing test1"/>        

  <target name="test2" depends="check_for_depend" if="${not.present}">
    <echo message="executing test2"/>        
  <target name="all" depends="test1,test2" /> 

View raw message