ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Mlodzinski <adam.mlodzin...@sitraka.com>
Subject Re: Return from task with BUILD SUCCESSFUL?
Date Fri, 11 Apr 2003 12:39:51 GMT
Have you considered reversing the logic of your <if>, so that if you 
need to start Tomcat, do that, and if not, do nothing?

<target name="start-local" depends="check-reach-local" description="Starts local Tomcat.">
    <if>
      <isset property="local.unreachable"/>
    <then>
      <echo message="Local Tomcat not running! Starting up..."/>
      <!-- START UP TOMCAT -->
      <echo message="Local Tomcat started up."/>
    </then>
    <echo message="Local Tomcat running!"/>
  </if>
</target>

You could also use an else clause:

<target name="start-local" depends="check-reach-local" description="Starts local Tomcat.">
    <if>
      <not>
        <isset property="local.unreachable"/>
      </not>
      <then>
         <echo message="Local Tomcat already running! Won't restart."/>
         <!-- simply fall through --> <!-- with BUILD SUCCESSFUL please -->
      </then>
      <else>
         <echo message="Local Tomcat not running! Starting up..."/>
         <!-- START UP TOMCAT -->
         <echo message="Local Tomcat started up."/>
      </else>
    </if> 
</target>



Karsten Wutzke wrote:

>Of course, my problem could be restated even simpler. I used the <trycatch> in hope
of successfully returning...
>
>It's basically a simple if-then construct with successful return from the target.
>
>    <!-- Start local Tomcat -->
>Any ideas?
>
>Karsten
>
>"Ant Users List" <user@ant.apache.org> schrieb am 11.04.03 03:17:41:
>  
>
>>Hi all!
>>
>>Is there any way in Ant to return from a target *successfully*, that is without printing
"BUILD FAILED"??? I would like a "BUILD SUCCESSFUL" message instead, so <fail> is no
go.
>>
>>I'm using an ant-contrib <trycatch> construct from inside an <if>, that
simply does some checking, and when an exception is caught, I want to print some information
and return from the task from inside the <catch>. Using <throw> from inside the
<catch> raises an exception in the IfTask class...
>>
>>  <!-- Start local Tomcat -->
>>  <target name="start-local" depends="check-reach-local" description="Starts local
Tomcat.">
>>    <if>
>>      <not>
>>        <isset property="local.unreachable"/>
>>      </not>
>>      <then>
>>        <trycatch>
>>          <try>
>>            <fail message="Intentional fail forced! See message below."/>
>>          </try>
>>          <catch>
>>            <echo message="Local Tomcat already running! Won't restart."/>
>>            <!--return/--> <!-- HOW? -->
>>          </catch>
>>        </trycatch>
>>      </then>
>>    </if>
>>
>>  <echo message="Local Tomcat not running! Starting up..."/>
>>
>>  <!-- START UP TOMCAT -->
>>
>>  <echo message="Local Tomcat started up."/>
>>
>></target>
>>
>>Any ideas? Stefan?
>>
>>Karsten
>>
>>PS: Maybe an ant-contrib <return> task would help?
>>PPS: Sorry for the <no subject> mail before, please ignore it
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>    
>>
>
>
>______________________________________________________________________________
>UNICEF bittet um Spenden fur die Kinder im Irak! Hier online an
>UNICEF spenden: https://spenden.web.de/unicef/special/?mc=021101
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>

-- 

Adam Mlodzinski
Software Developer
JClass QA
Quest Software
260 King St. E.
Toronto, ON M5A 4L5

Direct: 416-594-1026 x.729
Fax: 416-643-4850
Email: adam.mlodzinski@sitraka.com
http://www.quest.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message