You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Bohnet, Ralph" <rb...@netshepherd.com> on 2000/08/09 22:37:13 UTC
Using if/unless within a target
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>
<target name="test1" depends="check_for_depend" if="${string.present}">
<echo message="executing test1"/>
</target>
<target name="test2" depends="check_for_depend" if="${not.present}">
<echo message="executing test2"/>
</target>
<target name="all" depends="test1,test2" />
</project>
--------
Re: Using if/unless within a target
Posted by Cory Wandling <co...@ObjectDynamics.com>.
Using if/unless within a targetDon't put the ${} around the property.
----- Original Message -----
From: Bohnet, Ralph
To: 'ant-user@jakarta.apache.org'
Sent: Wednesday, August 09, 2000 3:37 PM
Subject: Using if/unless within a target
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>
<target name="test1" depends="check_for_depend" if="${string.present}">
<echo message="executing test1"/>
</target>
<target name="test2" depends="check_for_depend" if="${not.present}">
<echo message="executing test2"/>
</target>
<target name="all" depends="test1,test2" />
</project>
--------