ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Jackson" <>
Subject Retry task container
Date Sun, 13 May 2007 04:32:01 GMT
Hi all,

Looking through the bugzilla I came across, #28736 requesting a retry
attribute for the ftp task.

I thought instead that a generic Retry task container may be useful.
I've quickly thrown this together and first tests (using get) seem to
be fine, does anyone have an objection to adding this?

Use case:
- network operations may fail and cause a build to fail when all is
needed is another attempt

<retry noRetries="3">
  <get src="" dest=""/>


 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.

import java.util.Enumeration;
import java.util.Vector;


 * Retries the nested task a set number of times
public class Retry extends Task implements TaskContainer {

    private Vector nestedTasks = new Vector();

    private int noRetries;

    public void addTask(Task t) {

    public void setNoRetries(int n) {
        noRetries = n;

    public void execute() throws BuildException {
        for(Enumeration e = nestedTasks.elements(); e.hasMoreElements();) {
            Task t = (Task)e.nextElement();
            for(int i=0; i<noRetries; i++) {
                try {
                } catch (Exception ex) {
                    log("Attempt ["+i+"] error occured, retrying..." ,
ex, Project.MSG_INFO);
            try {
            } catch(Exception ex) {
                throw new BuildException("Failed after ["+noRetries+"]
attempts, giving up");


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message