git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270451 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -12,60 +12,32 @@ import java.util.EventObject; | |||
| public class BuildEvent | |||
| extends EventObject | |||
| { | |||
| private int priority = Project.MSG_VERBOSE; | |||
| private Throwable exception; | |||
| private String message; | |||
| private Project project; | |||
| private Target target; | |||
| private Task task; | |||
| /** | |||
| * Construct a BuildEvent for a project level event | |||
| * | |||
| * @param project the project that emitted the event. | |||
| */ | |||
| public BuildEvent( Project project ) | |||
| { | |||
| super( project ); | |||
| this.project = project; | |||
| this.target = null; | |||
| this.task = null; | |||
| } | |||
| private int m_priority = Project.MSG_VERBOSE; | |||
| private Throwable m_exception; | |||
| private String m_message; | |||
| private String m_target; | |||
| private String m_task; | |||
| /** | |||
| * Construct a BuildEvent for a target level event | |||
| * | |||
| * @param target the target that emitted the event. | |||
| */ | |||
| public BuildEvent( Target target ) | |||
| public BuildEvent( String target ) | |||
| { | |||
| super( target ); | |||
| this.project = target.getProject(); | |||
| this.target = target; | |||
| this.task = null; | |||
| } | |||
| /** | |||
| * Construct a BuildEvent for a task level event | |||
| * | |||
| * @param task the task that emitted the event. | |||
| */ | |||
| public BuildEvent( Task task ) | |||
| { | |||
| super( task ); | |||
| this.project = task.getProject(); | |||
| this.task = task; | |||
| m_target = target; | |||
| } | |||
| public void setException( Throwable exception ) | |||
| { | |||
| this.exception = exception; | |||
| m_exception = exception; | |||
| } | |||
| public void setMessage( String message, int priority ) | |||
| { | |||
| this.message = message; | |||
| this.priority = priority; | |||
| m_message = message; | |||
| m_priority = priority; | |||
| } | |||
| /** | |||
| @@ -79,7 +51,7 @@ public class BuildEvent | |||
| */ | |||
| public Throwable getException() | |||
| { | |||
| return exception; | |||
| return m_exception; | |||
| } | |||
| /** | |||
| @@ -91,7 +63,7 @@ public class BuildEvent | |||
| */ | |||
| public String getMessage() | |||
| { | |||
| return message; | |||
| return m_message; | |||
| } | |||
| /** | |||
| @@ -103,17 +75,7 @@ public class BuildEvent | |||
| */ | |||
| public int getPriority() | |||
| { | |||
| return priority; | |||
| } | |||
| /** | |||
| * Returns the project that fired this event. | |||
| * | |||
| * @return The Project value | |||
| */ | |||
| public Project getProject() | |||
| { | |||
| return project; | |||
| return m_priority; | |||
| } | |||
| /** | |||
| @@ -121,10 +83,9 @@ public class BuildEvent | |||
| * | |||
| * @return The Target value | |||
| */ | |||
| public Target getTarget() | |||
| public String getTarget() | |||
| { | |||
| return target; | |||
| return m_target; | |||
| } | |||
| /** | |||
| @@ -132,8 +93,8 @@ public class BuildEvent | |||
| * | |||
| * @return The Task value | |||
| */ | |||
| public Task getTask() | |||
| public String getTask() | |||
| { | |||
| return task; | |||
| return m_task; | |||
| } | |||
| } | |||
| @@ -13,13 +13,12 @@ import java.util.EventListener; | |||
| * Classes that implement this interface will be notified when things happend | |||
| * during a build. | |||
| * | |||
| * @author RT | |||
| * @see BuildEvent | |||
| * @see Project#addBuildListener(BuildListener) | |||
| */ | |||
| public interface BuildListener extends EventListener | |||
| public interface BuildListener | |||
| extends EventListener | |||
| { | |||
| /** | |||
| * Fired before any targets are started. | |||
| * | |||
| @@ -157,7 +157,7 @@ public class RecorderEntry | |||
| StringBuffer buf = new StringBuffer(); | |||
| if( event.getTask() != null ) | |||
| { | |||
| String name = "[" + event.getTask().getName() + "]"; | |||
| String name = "[" + event.getTask() + "]"; | |||
| /** | |||
| * @todo replace 12 with DefaultLogger.LEFT_COLUMN_SIZE | |||
| */ | |||
| @@ -180,10 +180,10 @@ public class RecorderEntry | |||
| out.flush(); | |||
| } | |||
| public void targetStarted( BuildEvent event ) | |||
| public void targetStarted( final BuildEvent event ) | |||
| { | |||
| getLogger().debug( ">> TARGET STARTED -- " + event.getTarget() ); | |||
| getLogger().info( LINE_SEP + event.getTarget().getName() + ":" ); | |||
| getLogger().info( LINE_SEP + event.getTarget() + ":" ); | |||
| targetStartTime = System.currentTimeMillis(); | |||
| } | |||
| @@ -1765,8 +1765,11 @@ public class VAJAntToolGUI extends Frame | |||
| if( event.getPriority() <= getBuildInfo().getOutputMessageLevel() ) | |||
| { | |||
| String msg = ""; | |||
| if( event.getTask() != null ) | |||
| msg = "[" + event.getTask().getName() + "] "; | |||
| final String task = event.getTask(); | |||
| if( task != null ) | |||
| { | |||
| msg = "[" + task + "] "; | |||
| } | |||
| getMessageTextArea().append( lineSeparator + msg + event.getMessage() ); | |||
| } | |||
| } | |||
| @@ -1792,7 +1795,7 @@ public class VAJAntToolGUI extends Frame | |||
| { | |||
| if( getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO ) | |||
| { | |||
| getMessageTextArea().append( lineSeparator + event.getTarget().getName() + ":" ); | |||
| getMessageTextArea().append( lineSeparator + event.getTarget() + ":" ); | |||
| } | |||
| } | |||
| @@ -22,6 +22,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; | |||
| import org.apache.tools.ant.BuildEvent; | |||
| import org.apache.tools.ant.BuildListener; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| /** | |||
| * This class is designed to be used by any AntTask that requires audio output. | |||
| @@ -34,6 +35,7 @@ import org.apache.tools.ant.Project; | |||
| * @version $Revision$, $Date$ | |||
| */ | |||
| public class AntSoundPlayer | |||
| extends AbstractLogEnabled | |||
| implements LineListener, BuildListener | |||
| { | |||
| private File m_fileSuccess; | |||
| @@ -80,7 +82,6 @@ public class AntSoundPlayer | |||
| * Fired after the last target has finished. This event will still be thrown | |||
| * if an error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void buildFinished( BuildEvent event ) | |||
| @@ -88,18 +89,16 @@ public class AntSoundPlayer | |||
| if( event.getException() == null && m_fileSuccess != null ) | |||
| { | |||
| // build successfull! | |||
| play( event.getProject(), m_fileSuccess, m_loopsSuccess, m_durationSuccess ); | |||
| play( m_fileSuccess, m_loopsSuccess, m_durationSuccess ); | |||
| } | |||
| else if( event.getException() != null && m_fileFail != null ) | |||
| { | |||
| play( event.getProject(), m_fileFail, m_loopsFail, m_durationFail ); | |||
| play( m_fileFail, m_loopsFail, m_durationFail ); | |||
| } | |||
| } | |||
| /** | |||
| * Fired before any targets are started. | |||
| * | |||
| * @param event Description of Parameter | |||
| */ | |||
| public void buildStarted( BuildEvent event ) | |||
| { | |||
| @@ -108,7 +107,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired whenever a message is logged. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getMessage() | |||
| * @see BuildEvent#getPriority() | |||
| */ | |||
| @@ -120,7 +118,6 @@ public class AntSoundPlayer | |||
| * Fired when a target has finished. This event will still be thrown if an | |||
| * error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void targetFinished( BuildEvent event ) | |||
| @@ -130,7 +127,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired when a target is started. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getTarget() | |||
| */ | |||
| public void targetStarted( BuildEvent event ) | |||
| @@ -141,7 +137,6 @@ public class AntSoundPlayer | |||
| * Fired when a task has finished. This event will still be throw if an | |||
| * error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void taskFinished( BuildEvent event ) | |||
| @@ -151,7 +146,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired when a task is started. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getTask() | |||
| */ | |||
| public void taskStarted( BuildEvent event ) | |||
| @@ -161,8 +155,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * This is implemented to listen for any line events and closes the clip if | |||
| * required. | |||
| * | |||
| * @param event Description of Parameter | |||
| */ | |||
| public void update( LineEvent event ) | |||
| { | |||
| @@ -184,15 +176,9 @@ public class AntSoundPlayer | |||
| /** | |||
| * Plays the file for duration milliseconds or loops. | |||
| * | |||
| * @param project Description of Parameter | |||
| * @param file Description of Parameter | |||
| * @param loops Description of Parameter | |||
| * @param duration Description of Parameter | |||
| */ | |||
| private void play( Project project, File file, int loops, Long duration ) | |||
| private void play( File file, int loops, Long duration ) | |||
| { | |||
| Clip audioClip = null; | |||
| AudioInputStream audioInputStream = null; | |||
| @@ -203,7 +189,8 @@ public class AntSoundPlayer | |||
| } | |||
| catch( UnsupportedAudioFileException uafe ) | |||
| { | |||
| project.getLogger().info( "Audio format is not yet supported: " + uafe.getMessage() ); | |||
| final String message = "Audio format is not yet supported: " + uafe.getMessage(); | |||
| getLogger().info( message ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -223,7 +210,8 @@ public class AntSoundPlayer | |||
| } | |||
| catch( LineUnavailableException e ) | |||
| { | |||
| project.getLogger().info( "The sound device is currently unavailable" ); | |||
| final String message = "The sound device is currently unavailable"; | |||
| getLogger().info( message ); | |||
| return; | |||
| } | |||
| catch( IOException e ) | |||
| @@ -244,7 +232,8 @@ public class AntSoundPlayer | |||
| } | |||
| else | |||
| { | |||
| project.getLogger().info( "Can't get data from file " + file.getName() ); | |||
| final String message = "Can't get data from file " + file.getName(); | |||
| getLogger().info( message ); | |||
| } | |||
| } | |||
| @@ -12,60 +12,32 @@ import java.util.EventObject; | |||
| public class BuildEvent | |||
| extends EventObject | |||
| { | |||
| private int priority = Project.MSG_VERBOSE; | |||
| private Throwable exception; | |||
| private String message; | |||
| private Project project; | |||
| private Target target; | |||
| private Task task; | |||
| /** | |||
| * Construct a BuildEvent for a project level event | |||
| * | |||
| * @param project the project that emitted the event. | |||
| */ | |||
| public BuildEvent( Project project ) | |||
| { | |||
| super( project ); | |||
| this.project = project; | |||
| this.target = null; | |||
| this.task = null; | |||
| } | |||
| private int m_priority = Project.MSG_VERBOSE; | |||
| private Throwable m_exception; | |||
| private String m_message; | |||
| private String m_target; | |||
| private String m_task; | |||
| /** | |||
| * Construct a BuildEvent for a target level event | |||
| * | |||
| * @param target the target that emitted the event. | |||
| */ | |||
| public BuildEvent( Target target ) | |||
| public BuildEvent( String target ) | |||
| { | |||
| super( target ); | |||
| this.project = target.getProject(); | |||
| this.target = target; | |||
| this.task = null; | |||
| } | |||
| /** | |||
| * Construct a BuildEvent for a task level event | |||
| * | |||
| * @param task the task that emitted the event. | |||
| */ | |||
| public BuildEvent( Task task ) | |||
| { | |||
| super( task ); | |||
| this.project = task.getProject(); | |||
| this.task = task; | |||
| m_target = target; | |||
| } | |||
| public void setException( Throwable exception ) | |||
| { | |||
| this.exception = exception; | |||
| m_exception = exception; | |||
| } | |||
| public void setMessage( String message, int priority ) | |||
| { | |||
| this.message = message; | |||
| this.priority = priority; | |||
| m_message = message; | |||
| m_priority = priority; | |||
| } | |||
| /** | |||
| @@ -79,7 +51,7 @@ public class BuildEvent | |||
| */ | |||
| public Throwable getException() | |||
| { | |||
| return exception; | |||
| return m_exception; | |||
| } | |||
| /** | |||
| @@ -91,7 +63,7 @@ public class BuildEvent | |||
| */ | |||
| public String getMessage() | |||
| { | |||
| return message; | |||
| return m_message; | |||
| } | |||
| /** | |||
| @@ -103,17 +75,7 @@ public class BuildEvent | |||
| */ | |||
| public int getPriority() | |||
| { | |||
| return priority; | |||
| } | |||
| /** | |||
| * Returns the project that fired this event. | |||
| * | |||
| * @return The Project value | |||
| */ | |||
| public Project getProject() | |||
| { | |||
| return project; | |||
| return m_priority; | |||
| } | |||
| /** | |||
| @@ -121,10 +83,9 @@ public class BuildEvent | |||
| * | |||
| * @return The Target value | |||
| */ | |||
| public Target getTarget() | |||
| public String getTarget() | |||
| { | |||
| return target; | |||
| return m_target; | |||
| } | |||
| /** | |||
| @@ -132,8 +93,8 @@ public class BuildEvent | |||
| * | |||
| * @return The Task value | |||
| */ | |||
| public Task getTask() | |||
| public String getTask() | |||
| { | |||
| return task; | |||
| return m_task; | |||
| } | |||
| } | |||
| @@ -13,13 +13,12 @@ import java.util.EventListener; | |||
| * Classes that implement this interface will be notified when things happend | |||
| * during a build. | |||
| * | |||
| * @author RT | |||
| * @see BuildEvent | |||
| * @see Project#addBuildListener(BuildListener) | |||
| */ | |||
| public interface BuildListener extends EventListener | |||
| public interface BuildListener | |||
| extends EventListener | |||
| { | |||
| /** | |||
| * Fired before any targets are started. | |||
| * | |||
| @@ -157,7 +157,7 @@ public class RecorderEntry | |||
| StringBuffer buf = new StringBuffer(); | |||
| if( event.getTask() != null ) | |||
| { | |||
| String name = "[" + event.getTask().getName() + "]"; | |||
| String name = "[" + event.getTask() + "]"; | |||
| /** | |||
| * @todo replace 12 with DefaultLogger.LEFT_COLUMN_SIZE | |||
| */ | |||
| @@ -180,10 +180,10 @@ public class RecorderEntry | |||
| out.flush(); | |||
| } | |||
| public void targetStarted( BuildEvent event ) | |||
| public void targetStarted( final BuildEvent event ) | |||
| { | |||
| getLogger().debug( ">> TARGET STARTED -- " + event.getTarget() ); | |||
| getLogger().info( LINE_SEP + event.getTarget().getName() + ":" ); | |||
| getLogger().info( LINE_SEP + event.getTarget() + ":" ); | |||
| targetStartTime = System.currentTimeMillis(); | |||
| } | |||
| @@ -1765,8 +1765,11 @@ public class VAJAntToolGUI extends Frame | |||
| if( event.getPriority() <= getBuildInfo().getOutputMessageLevel() ) | |||
| { | |||
| String msg = ""; | |||
| if( event.getTask() != null ) | |||
| msg = "[" + event.getTask().getName() + "] "; | |||
| final String task = event.getTask(); | |||
| if( task != null ) | |||
| { | |||
| msg = "[" + task + "] "; | |||
| } | |||
| getMessageTextArea().append( lineSeparator + msg + event.getMessage() ); | |||
| } | |||
| } | |||
| @@ -1792,7 +1795,7 @@ public class VAJAntToolGUI extends Frame | |||
| { | |||
| if( getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO ) | |||
| { | |||
| getMessageTextArea().append( lineSeparator + event.getTarget().getName() + ":" ); | |||
| getMessageTextArea().append( lineSeparator + event.getTarget() + ":" ); | |||
| } | |||
| } | |||
| @@ -22,6 +22,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; | |||
| import org.apache.tools.ant.BuildEvent; | |||
| import org.apache.tools.ant.BuildListener; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| /** | |||
| * This class is designed to be used by any AntTask that requires audio output. | |||
| @@ -34,6 +35,7 @@ import org.apache.tools.ant.Project; | |||
| * @version $Revision$, $Date$ | |||
| */ | |||
| public class AntSoundPlayer | |||
| extends AbstractLogEnabled | |||
| implements LineListener, BuildListener | |||
| { | |||
| private File m_fileSuccess; | |||
| @@ -80,7 +82,6 @@ public class AntSoundPlayer | |||
| * Fired after the last target has finished. This event will still be thrown | |||
| * if an error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void buildFinished( BuildEvent event ) | |||
| @@ -88,18 +89,16 @@ public class AntSoundPlayer | |||
| if( event.getException() == null && m_fileSuccess != null ) | |||
| { | |||
| // build successfull! | |||
| play( event.getProject(), m_fileSuccess, m_loopsSuccess, m_durationSuccess ); | |||
| play( m_fileSuccess, m_loopsSuccess, m_durationSuccess ); | |||
| } | |||
| else if( event.getException() != null && m_fileFail != null ) | |||
| { | |||
| play( event.getProject(), m_fileFail, m_loopsFail, m_durationFail ); | |||
| play( m_fileFail, m_loopsFail, m_durationFail ); | |||
| } | |||
| } | |||
| /** | |||
| * Fired before any targets are started. | |||
| * | |||
| * @param event Description of Parameter | |||
| */ | |||
| public void buildStarted( BuildEvent event ) | |||
| { | |||
| @@ -108,7 +107,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired whenever a message is logged. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getMessage() | |||
| * @see BuildEvent#getPriority() | |||
| */ | |||
| @@ -120,7 +118,6 @@ public class AntSoundPlayer | |||
| * Fired when a target has finished. This event will still be thrown if an | |||
| * error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void targetFinished( BuildEvent event ) | |||
| @@ -130,7 +127,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired when a target is started. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getTarget() | |||
| */ | |||
| public void targetStarted( BuildEvent event ) | |||
| @@ -141,7 +137,6 @@ public class AntSoundPlayer | |||
| * Fired when a task has finished. This event will still be throw if an | |||
| * error occured during the build. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void taskFinished( BuildEvent event ) | |||
| @@ -151,7 +146,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * Fired when a task is started. | |||
| * | |||
| * @param event Description of Parameter | |||
| * @see BuildEvent#getTask() | |||
| */ | |||
| public void taskStarted( BuildEvent event ) | |||
| @@ -161,8 +155,6 @@ public class AntSoundPlayer | |||
| /** | |||
| * This is implemented to listen for any line events and closes the clip if | |||
| * required. | |||
| * | |||
| * @param event Description of Parameter | |||
| */ | |||
| public void update( LineEvent event ) | |||
| { | |||
| @@ -184,15 +176,9 @@ public class AntSoundPlayer | |||
| /** | |||
| * Plays the file for duration milliseconds or loops. | |||
| * | |||
| * @param project Description of Parameter | |||
| * @param file Description of Parameter | |||
| * @param loops Description of Parameter | |||
| * @param duration Description of Parameter | |||
| */ | |||
| private void play( Project project, File file, int loops, Long duration ) | |||
| private void play( File file, int loops, Long duration ) | |||
| { | |||
| Clip audioClip = null; | |||
| AudioInputStream audioInputStream = null; | |||
| @@ -203,7 +189,8 @@ public class AntSoundPlayer | |||
| } | |||
| catch( UnsupportedAudioFileException uafe ) | |||
| { | |||
| project.getLogger().info( "Audio format is not yet supported: " + uafe.getMessage() ); | |||
| final String message = "Audio format is not yet supported: " + uafe.getMessage(); | |||
| getLogger().info( message ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -223,7 +210,8 @@ public class AntSoundPlayer | |||
| } | |||
| catch( LineUnavailableException e ) | |||
| { | |||
| project.getLogger().info( "The sound device is currently unavailable" ); | |||
| final String message = "The sound device is currently unavailable"; | |||
| getLogger().info( message ); | |||
| return; | |||
| } | |||
| catch( IOException e ) | |||
| @@ -244,7 +232,8 @@ public class AntSoundPlayer | |||
| } | |||
| else | |||
| { | |||
| project.getLogger().info( "Can't get data from file " + file.getName() ); | |||
| final String message = "Can't get data from file " + file.getName(); | |||
| getLogger().info( message ); | |||
| } | |||
| } | |||