ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: AW: if / unless ... Misanderstanding or problem ... ?
Date Thu, 12 Aug 2004 11:11:27 GMT
The if attribute in the target checks for the existeance
of a property and not the value of the property.

In the run.2 target you have unless="${exploded}"
the ${exploded} gets expanded to true
so the run.2 target is:
<target name="run.2" depends="..." unless="true">
   <echo ../>
</target>

The property "true" is not defined, so the target's contents
are run.

Peter

Thomas SMETS wrote:

>So why do I see :
>
>      run.2:
>            [echo] Hello 2
>I have no problem having 2.1 & 2.1 being executed...
>but I should not see  "Hello 2 " anyhow
>
>\T,
>
>
>
>
>  
>
>>Nothing went wrong, you´re only expecting another behaviour :-)
>>
>>1. executed dependend targets
>>2. evaluate if/unless
>>3. execute the target according to step 2
>>
>>Thats because you´ll often have a construct like
>>
>><target name="check">
>>   <condition property="ok"> ...
>></target>
>><target name="do" depends="check" if="ok">
>>   <echo> all ok</echo>
>></target>
>>
>>
>>Jan
>>
>>
>>
>>
>>    
>>
>>>-----Ursprüngliche Nachricht-----
>>>Von: Thomas SMETS [mailto:tsmets@tsmets.lautre.net]
>>>Gesendet am: Donnerstag, 12. August 2004 12:56
>>>An: user@ant.apache.org
>>>Betreff: if / unless ... Misanderstanding or problem ... ?
>>>
>>>
>>>Here is my build file :
>>><project name="Test"
>>>		 default="run"
>>>		 basedir=".">
>>>
>>>  <!-- set global properties for this build -->
>>>  <property file="build.properties"/>
>>>
>>>  <target name="run.1.1" >
>>>  	<echo>Hello 1.1</echo>
>>>  </target>
>>>
>>>  <target name="run.1.2"  >
>>>  	<echo>Hello 1.2 </echo>
>>>  </target>
>>>
>>>  <target name="run.2.1" >
>>>  	<echo>Hello 2.1</echo>
>>>  </target>
>>>
>>>  <target name="run.2.2"  >
>>>  	<echo>Hello 2.2 </echo>
>>>  </target>
>>>
>>>  <target name="run.1"
>>>  		  depends="run.1.1,run.1.2"
>>>  		  if="${exploded}">
>>>  	<echo>Hello 1 </echo>
>>>  </target>
>>>
>>>  <target name="run.2"
>>>  		  depends="run.2.1,run.2.2"
>>>  		  unless="${exploded}">
>>>  	<echo>Hello 2 </echo>
>>>  </target>
>>>
>>>
>>>  <target name="run"
>>>  		  depends="run.1,run.2" >
>>>  	<echo>Hello
>>>  		exploded = ${exploded} </echo>
>>>  </target>
>>></project>
>>>
>>>
>>>In the "build.properties" files, I have only the following line :
>>>
>>>exploded = true
>>>
>>>Now the problemis that the outcome is the following :
>>>ant -buildfile Test.xml
>>>Buildfile: Test.xml
>>>
>>>run.1.1:
>>>     [echo] Hello 1.1
>>>
>>>run.1.2:
>>>     [echo] Hello 1.2
>>>
>>>run.1:
>>>
>>>run.2.1:
>>>     [echo] Hello 2.1
>>>
>>>run.2.2:
>>>     [echo] Hello 2.2
>>>
>>>run.2:
>>>     [echo] Hello 2
>>>
>>>run:
>>>     [echo] Hello
>>>     [echo]             exploded = true
>>>
>>>BUILD SUCCESSFUL
>>>Total time: 0 seconds
>>>
>>>
>>>JDK is the 1.4 provided with BEA 8.1
>>>ANT is 1.6.2
>>>
>>>Any hint in what goes wrong ... ?
>>>
>>>\T,
>>>
>>>
>>>
>>>--
>>>Thomas SMETS
>>>rue J. Wytsmanstraat 62
>>>1050 Brussels
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>      
>>>
>
>
>  
>


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


Mime
View raw message