ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karsten Wutzke <kwut...@starconcept.de>
Subject Conditional if/unless echo
Date Thu, 10 Apr 2003 13:17:25 GMT
Hello all!

I still don't see why there is no if/unless support for the <echo> 
task...! It's even something I'd find *mandatory* for many other tasks, 
if not all. The <fail> task has that feature already, beats me why it's 
not in <echo>.

Anyway, is there really no other solution but to create conditional 
targets that are only used to echo? Is there at least a solution to use 
a target as an entry point for all conditional echos, so that the 
condition (==value of property) and message get passed to the target 
e.g. via <antcall>

I tried:

<target name="echo-ifset" if="${echo.cond}">
   <echo message="${echo.msg}"/>
</target>

<target name="echo-ifnotset" unless="${echo.cond}">
   <echo message="${echo.msg}"/>
</target>

<!-- Try to reach local Tomcat -->
<target name="check-reach-local" depends="check-inst-local" 
description="Tries to reach the local Tomcat server.">
   <waitfor timeoutproperty="local.unreachable" maxwait="2000" 
maxwaitunit="millisecond">
     <socket server="${local.server}" port="${local.port}"/>
   </waitfor>

   <antcall target="echo-ifset">
     <param name="echo.cond" value="${local.unreachable}"/>
     <param name="echo.msg"  value="Local Tomcat server *not* reachable 
at '${local.server}:${local.port}'."/>
   </antcall>

   <antcall target="echo-ifnotset">
     <param name="echo.cond" value="${local.unreachable}"/>
     <param name="echo.msg"  value="Local Tomcat server reachable at 
'${local.server}:${local.port}'."/>
   </antcall>

</target>


Which obviously doesn't work... My guess is, that during the <antcall> 
the value "${local.unreachable}" is always assigned to echo.cond 
property, which leads to always omitting the execution of the isset 
(a.k.a if condition) target...

Isn't there an easier solution? I simply want to print the status of 
sometimes, but I have no (good) idea. Do I really have to create a task 
for each conditional echo I want?

Thanks!

Karsten



Mime
View raw message