package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.*;

/**
 * This is an ANT task that is able to sleep for a specified
 * period of time.
 *
 * @author Robert L. Shaw
 */
public class Sleep extends Task {
    private long millis = -1L;

    /**
     * Set the length of time to sleep in milliseconds.
     */
    public void setMillis(long value) {
        millis = value;
    }

    public void execute() throws BuildException {

        if (millis < 0 ) {
            throw new BuildException("You need to specify a positive length of " +
                                     "time to sleep in milliseconds.");
        }

        try {

            Thread.currentThread().sleep(millis);

        } catch (Exception e) {
            e.printStackTrace();
            throw new BuildException(e);
        }
    }
}
