ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Taylor <donald_l_taylor...@yahoo.com>
Subject RE: Retry task on Error
Date Thu, 28 Jun 2001 12:23:54 GMT
I've never used the 'script' task in Ant. So after getting bsf.jar and
js.jar on my system (after several unsuccessful attempts at running
this build) I can't seem to catch *any* exception, including
java.lang.Exception. The script engine always generates an error. If I
remove the try/catch clause it's happy.

Is this the question you're really asking, is it possible to catch
exceptions in scripts? Sure doesn't seem so. I've checked all the
archives and I can't see where this issue's been discussed before (I
thought it had, but I can't find it.)


--- "Samson, Lyndon [IT]" <lyndon.samson@ssmb.com> wrote:
> I tried this;
> 
> <project name="test" default="main" basedir=".">
> 
>     <target name="makeItSo" >
>         <echo2>Make it so Number 1</echo2>
>     </target>
> 
>     <target name="rptonfail" >
> 
>         <script language="javascript"> <![CDATA[
>             var notDone = true;
>             var x = 0;
>             while ( notDone ) {
>                 notDone = false;
>                 try {
>                     test.executeTarget("makeItSo"); 
>                 } catch ( BuildException e ) {
>                     java.lang.System.out.println("Build failed");
>                     notDone = true;
>                 }
> 
>             }
> 
>         ]]> </script>
>     </target>
> 
>     <target name="main" description="Do the business" >
>         <antcall target="rptonfail"/>
>     </target>
> 
> </project>
> 
> But for some reason I can't catch the BuildException????
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Don Taylor [mailto:donald_l_taylor_jr@yahoo.com]
> Sent: Wednesday, June 27, 2001 6:24 PM
> To: ant-user@jakarta.apache.org
> Subject: RE: Retry task on Error
> 
> 
> I was genericizing it, obviously the 'ftp.ok' property has to be
> conditionally set possibly via the use of additional tasks. I don't
> know how he plans on checking if his FTP succeeded, but if it were
> me,
> I'd probably just use the uptodate task and make 'ftp.ok' it's target
> property.
> 
> You can *always* use more coffee!  :-)
> 
> 
> --- Diane Holt <holtdl@yahoo.com> wrote:
> > --- Don Taylor <donald_l_taylor_jr@yahoo.com> wrote:
> > > Ok. Actually it just requires a small modification:
> > > 
> > > <target name="checkFTPfailure">
> > >   <!-- Do whatever to determine FTP failure.
> > >        (Using 'uptodate' task?)
> > >        If FTP has succeeded, set a property.
> > >   -->
> > >   <property name="ftp.ok" value="true"/>
> > > </target>
> > 
> > Don,
> > 
> > How do you see this working?  What will prevent the <property> task
> > from
> > being run regardless of what <uptodate> results in?
> > 
> > I suspect what you want is to set the property in the <uptodate>
> task
> > alone (assuming using <uptodate> would be able to be used as the
> > determiner of whether the FTP task succeeded, although I'm not sure
> > what
> > you have in mind it would check for).
> > 
> > (Or maybe I just need some coffee and I'm not seeing it...)
> > 
> > Diane
> >  
> > 
> > > <target name="ftpLoop" depends="checkFTPfailure" unless="ftp.ok">
> > >   <FTP .../>
> > >   <antcall target="ftpLoop2"/>
> > > </target>
> > > 
> > > <target name="ftpLoop2" depends="checkFTPfailure"
> unless="ftp.ok">
> > >   <FTP .../>
> > >   <antcall target="ftpLoop"/>
> > > </target>
> > > 
> > > <target name="ftp" depends="ftpLoop"/>
> > > 
> > > Note that 'checkFTPfailure' will be called *before* you attempt
> > your
> > > first FTP. This should be fine, since you haven't even attempted
> an
> > FTP
> > > yet that *certainly* should be a failure!  :)
> > > 
> > > - Don
> > > 
> > > 
> > > --- "O'Hara, Patrick" <patrick.ohara@workscape.com> wrote:
> > > > Yes I was hoping for a loop until successful.
> > > > 
> > > > Patrick O'Hara
> > > > 262-408-3849
> > > > patrick.ohara@workscape.com
> > > > 
> > > > 
> > > > 
> > > > 
> > > > -----Original Message-----
> > > > From: Don Taylor [mailto:donald_l_taylor_jr@yahoo.com]
> > > > Sent: Wednesday, June 27, 2001 9:29 AM
> > > > To: ant-user@jakarta.apache.org
> > > > Subject: Re: Retry task on Error
> > > > 
> > > > 
> > > > 
> > > > --- "O'Hara, Patrick" <patrick.ohara@workscape.com> wrote:
> > > > > Is there a way to retry a task when it errors out?  I have a
> > FTP
> > > > > task.  The
> > > > > server we are connecting to is a little hit and miss.  I
> would
> > like
> > > > > to retry
> > > > > the FTP task if it fails to send all the files.
> > > > > 
> > > > 
> > > > I'm assuming you can already figure out if the FTP task has
> > failed.
> > > > Put
> > > > that logic in a target:
> > > > 
> > > > <target name="checkFTPfailure">
> > > >   <!-- Do whatever to determine FTP failure.
> > > >        (Using 'uptodate' task?)
> > > >        If FTP has failed, set a property.
> > > >   -->
> > > >   <property name="ftp.failed" value="true"/>
> > > > </target>
> > > > 
> > > > 
> > > > Now you're ready to try your FTP:
> > > > 
> > > > <target name="ftpFirst">
> > > >    <FTP .../>
> > > > </target>
> > > > 
> > > > <target name="ftpSecond" depends="checkFTPfailure"
> > > > unless="ftp.failed">
> > > >    <FTP .../>
> > > > </target>
> > > > 
> > > > <target name="ftp" depends="ftpFirst,ftpSecond"/>
> > > > 
> > > > You see your 'ftp' target will FTP your files, and failing
> that,
> > will
> > > > try again. If you desire to loop until the FTP is complete, let
> > me
> > > > know, that's a lot trickier (but possible.)
> > > > 
> > > > - Don
> > > > 
> > > > 
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Get personalized email addresses from Yahoo! Mail
> > > > http://personal.mail.yahoo.com/
> > > > 
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get personalized email addresses from Yahoo! Mail
> > > http://personal.mail.yahoo.com/
> > 
> > 
> > =====
> > (holtdl@yahoo.com)
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
> 
> 
> =====
> 
=== message truncated ===


=====
Don

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Mime
View raw message