diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties new file mode 100644 index 000000000..b84e44e91 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties @@ -0,0 +1,6 @@ +sleep.duration.notice=Sleeping for {0} milliseconds. +sleep.neg-time.error=Negative sleep periods are not supported. + +patch.missing-file.error=Patchfile argument is required. +patch.file-noexist.error=Patchfile "{0}" doesn\'t exist. +patch.neg-strip.error=Strip has to be >= 0 diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java b/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java new file mode 100644 index 000000000..d068c99d8 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.antlib.build; + +import org.apache.avalon.excalibur.i18n.ResourceManager; +import org.apache.avalon.excalibur.i18n.Resources; +import org.apache.myrmidon.api.AbstractTask; +import org.apache.myrmidon.api.TaskException; + +/** + * A task to sleep for a period of time + * + * @author steve_l@iseran.com steve loughran + * @created 01 May 2001 + */ +public class SleepTask + extends AbstractTask +{ + private final static Resources REZ = + ResourceManager.getPackageResources( SleepTask.class ); + + private int m_seconds; + private int m_hours; + private int m_minutes; + private int m_milliseconds; + + /** + * Sets the Hours attribute of the Sleep object + */ + public void setHours( final int hours ) + { + m_hours = hours; + } + + /** + * Sets the Milliseconds attribute of the Sleep object + */ + public void setMilliseconds( final int milliseconds ) + { + m_milliseconds = milliseconds; + } + + /** + * Sets the Minutes attribute of the Sleep object + */ + public void setMinutes( final int minutes ) + { + m_minutes = minutes; + } + + /** + * Sets the Seconds attribute of the Sleep object + */ + public void setSeconds( final int seconds ) + { + m_seconds = seconds; + } + + /** + * sleep for a period of time + * + * @param millis time to sleep + */ + private void doSleep( final long millis ) + { + try + { + Thread.currentThread().sleep( millis ); + } + catch( InterruptedException ie ) + { + } + } + + /** + * Executes this build task. throws org.apache.tools.ant.TaskException if + * there is an error during task execution. + * + * @exception TaskException Description of Exception + */ + public void execute() + throws TaskException + { + validate(); + final long sleepTime = getSleepTime(); + + final String message = REZ.getString( "sleep.duration.notice", new Long( sleepTime ) ); + getLogger().debug( message ); + + doSleep( sleepTime ); + } + + /** + * verify parameters + * + * @throws TaskException if something is invalid + */ + private void validate() + throws TaskException + { + if( getSleepTime() < 0 ) + { + final String message = REZ.getString( "sleep.neg-time.error" ); + throw new TaskException( message ); + } + } + + /** + * return time to sleep + * + * @return sleep time. if below 0 then there is an error + */ + private long getSleepTime() + { + return ( ( ( (long)m_hours * 60 ) + m_minutes ) * 60 + m_seconds ) * 1000 + m_milliseconds; + } +} + diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java deleted file mode 100644 index a5c5972f9..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; - -/** - * A task to sleep for a period of time - * - * @author steve_l@iseran.com steve loughran - * @created 01 May 2001 - */ - -public class Sleep extends Task -{ - /** - * failure flag - */ - private boolean failOnError = true; - - /** - * Description of the Field - */ - private int seconds = 0; - /** - * Description of the Field - */ - private int hours = 0; - /** - * Description of the Field - */ - private int minutes = 0; - /** - * Description of the Field - */ - private int milliseconds = 0; - - /** - * Creates new instance - */ - public Sleep() - { - } - - /** - * Sets the FailOnError attribute of the MimeMail object - * - * @param failOnError The new FailOnError value - */ - public void setFailOnError( boolean failOnError ) - { - this.failOnError = failOnError; - } - - /** - * Sets the Hours attribute of the Sleep object - * - * @param hours The new Hours value - */ - public void setHours( int hours ) - { - this.hours = hours; - } - - /** - * Sets the Milliseconds attribute of the Sleep object - * - * @param milliseconds The new Milliseconds value - */ - public void setMilliseconds( int milliseconds ) - { - this.milliseconds = milliseconds; - } - - /** - * Sets the Minutes attribute of the Sleep object - * - * @param minutes The new Minutes value - */ - public void setMinutes( int minutes ) - { - this.minutes = minutes; - } - - /** - * Sets the Seconds attribute of the Sleep object - * - * @param seconds The new Seconds value - */ - public void setSeconds( int seconds ) - { - this.seconds = seconds; - } - - /** - * sleep for a period of time - * - * @param millis time to sleep - */ - public void doSleep( long millis ) - { - try - { - Thread.currentThread().sleep( millis ); - } - catch( InterruptedException ie ) - { - } - } - - /** - * Executes this build task. throws org.apache.tools.ant.TaskException if - * there is an error during task execution. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - try - { - validate(); - long sleepTime = getSleepTime(); - getLogger().debug( "sleeping for " + sleepTime + " milliseconds" ); - doSleep( sleepTime ); - } - catch( Exception e ) - { - if( failOnError ) - { - throw new TaskException( "Error", e ); - } - else - { - String text = e.toString(); - getLogger().error( text ); - } - } - } - - /** - * verify parameters - * - * @throws TaskException if something is invalid - */ - public void validate() - throws TaskException - { - long sleepTime = getSleepTime(); - if( getSleepTime() < 0 ) - { - throw new TaskException( "Negative sleep periods are not supported" ); - } - } - - /** - * return time to sleep - * - * @return sleep time. if below 0 then there is an error - */ - - private long getSleepTime() - { - return ( ( ( (long)hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds; - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java deleted file mode 100644 index a5c5972f9..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; - -/** - * A task to sleep for a period of time - * - * @author steve_l@iseran.com steve loughran - * @created 01 May 2001 - */ - -public class Sleep extends Task -{ - /** - * failure flag - */ - private boolean failOnError = true; - - /** - * Description of the Field - */ - private int seconds = 0; - /** - * Description of the Field - */ - private int hours = 0; - /** - * Description of the Field - */ - private int minutes = 0; - /** - * Description of the Field - */ - private int milliseconds = 0; - - /** - * Creates new instance - */ - public Sleep() - { - } - - /** - * Sets the FailOnError attribute of the MimeMail object - * - * @param failOnError The new FailOnError value - */ - public void setFailOnError( boolean failOnError ) - { - this.failOnError = failOnError; - } - - /** - * Sets the Hours attribute of the Sleep object - * - * @param hours The new Hours value - */ - public void setHours( int hours ) - { - this.hours = hours; - } - - /** - * Sets the Milliseconds attribute of the Sleep object - * - * @param milliseconds The new Milliseconds value - */ - public void setMilliseconds( int milliseconds ) - { - this.milliseconds = milliseconds; - } - - /** - * Sets the Minutes attribute of the Sleep object - * - * @param minutes The new Minutes value - */ - public void setMinutes( int minutes ) - { - this.minutes = minutes; - } - - /** - * Sets the Seconds attribute of the Sleep object - * - * @param seconds The new Seconds value - */ - public void setSeconds( int seconds ) - { - this.seconds = seconds; - } - - /** - * sleep for a period of time - * - * @param millis time to sleep - */ - public void doSleep( long millis ) - { - try - { - Thread.currentThread().sleep( millis ); - } - catch( InterruptedException ie ) - { - } - } - - /** - * Executes this build task. throws org.apache.tools.ant.TaskException if - * there is an error during task execution. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - try - { - validate(); - long sleepTime = getSleepTime(); - getLogger().debug( "sleeping for " + sleepTime + " milliseconds" ); - doSleep( sleepTime ); - } - catch( Exception e ) - { - if( failOnError ) - { - throw new TaskException( "Error", e ); - } - else - { - String text = e.toString(); - getLogger().error( text ); - } - } - } - - /** - * verify parameters - * - * @throws TaskException if something is invalid - */ - public void validate() - throws TaskException - { - long sleepTime = getSleepTime(); - if( getSleepTime() < 0 ) - { - throw new TaskException( "Negative sleep periods are not supported" ); - } - } - - /** - * return time to sleep - * - * @return sleep time. if below 0 then there is an error - */ - - private long getSleepTime() - { - return ( ( ( (long)hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds; - } - -} -