diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java index 5a6cdb9d4..99de9073d 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java @@ -41,6 +41,7 @@ import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.type.TypeFactory; import org.apache.myrmidon.interfaces.type.TypeManager; import org.apache.myrmidon.interfaces.workspace.Workspace; +import org.apache.myrmidon.listeners.ProjectListener; /** * Default implementation of Embeddor. @@ -126,6 +127,19 @@ public class DefaultEmbeddor return workspace; } + /** + * Creates a project listener. + * + * @param name The shorthand name of the listener. + * @return the listener. + */ + public ProjectListener createListener( String name ) + throws Exception + { + final TypeFactory factory = m_typeManager.getFactory( ProjectListener.class ); + return (ProjectListener)factory.create( name ); + } + /** * Initialize the system. * diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java index 775d5d402..a9da9aede 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java @@ -130,13 +130,13 @@ public class DefaultWorkspace { final ProjectEntry entry = getProjectEntry( project ); - m_listenerSupport.projectStarted(); + m_listenerSupport.projectStarted( project.getProjectName() ); executeTarget( "", project.getImplicitTarget(), entry.getFrame() ); execute( project, target, entry ); - m_listenerSupport.projectFinished(); + m_listenerSupport.projectFinished( project.getProjectName() ); } private TaskContext createBaseContext() @@ -383,7 +383,7 @@ public class DefaultWorkspace } //notify listeners - m_listenerSupport.targetStarted( targetName ); + m_listenerSupport.targetStarted( project.getProjectName(), targetName ); executeTarget( targetName, target, entry.getFrame() ); diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/LogTargetToListenerAdapter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/LogTargetToListenerAdapter.java index b3bad648c..dea67b1ab 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/LogTargetToListenerAdapter.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/LogTargetToListenerAdapter.java @@ -20,16 +20,16 @@ import org.apache.myrmidon.listeners.ProjectListener; public class LogTargetToListenerAdapter implements LogTarget { - private final ProjectListener m_listener; + private final ProjectListenerSupport m_listenerSupport; /** * Constructor taking listener to convert to. * - * @param listener the ProjectListener + * @param listenerSupport the ProjectListener */ - public LogTargetToListenerAdapter( final ProjectListener listener ) + public LogTargetToListenerAdapter( final ProjectListenerSupport listenerSupport ) { - m_listener = listener; + m_listenerSupport = listenerSupport; } /** @@ -39,13 +39,6 @@ public class LogTargetToListenerAdapter */ public void processEvent( final LogEvent event ) { - if( null == event.getThrowable() ) - { - m_listener.log( event.getMessage() ); - } - else - { - m_listener.log( event.getMessage(), event.getThrowable() ); - } + m_listenerSupport.log( event.getMessage(), event.getThrowable() ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/ProjectListenerSupport.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/ProjectListenerSupport.java index a279219a1..09d5a424b 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/ProjectListenerSupport.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/ProjectListenerSupport.java @@ -8,6 +8,10 @@ package org.apache.myrmidon.components.workspace; import org.apache.myrmidon.listeners.ProjectListener; +import org.apache.myrmidon.listeners.ProjectEvent; +import org.apache.myrmidon.listeners.TargetEvent; +import org.apache.myrmidon.listeners.TaskEvent; +import org.apache.myrmidon.listeners.LogEvent; /** * Support for the project listener event dispatching. @@ -16,9 +20,14 @@ import org.apache.myrmidon.listeners.ProjectListener; * @version $Revision$ $Date$ */ public class ProjectListenerSupport - implements ProjectListener + implements LogEvent { private ProjectListener[] m_listeners = new ProjectListener[ 0 ]; + private String m_projectName; + private String m_targetName; + private String m_taskName; + private String m_message; + private Throwable m_throwable; /** * Add an extra project listener that wants to receive notification of listener events. @@ -68,35 +77,47 @@ public class ProjectListenerSupport /** * Fire a projectStarted event. */ - public void projectStarted() + public void projectStarted( final String projectName ) { + m_projectName = projectName; + m_targetName = null; + m_taskName = null; + for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].projectStarted(); + m_listeners[ i ].projectStarted( this ); } } /** * Fire a projectFinished event. */ - public void projectFinished() + public void projectFinished( final String projectName ) { + m_projectName = projectName; + for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].projectFinished(); + m_listeners[ i ].projectFinished( this ); } + + m_projectName = null; + m_targetName = null; + m_taskName = null; } /** * Fire a targetStarted event. - * - * @param targetName the name of target */ - public void targetStarted( String targetName ) + public void targetStarted( final String projectName, final String targetName ) { + m_projectName = projectName; + m_targetName = targetName;; + m_taskName = null; + for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].targetStarted( targetName ); + m_listeners[ i ].targetStarted( this ); } } @@ -107,20 +128,23 @@ public class ProjectListenerSupport { for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].targetFinished(); + m_listeners[ i ].targetFinished( this ); } + + m_targetName = null; + m_taskName = null; } /** * Fire a targetStarted event. - * - * @param targetName the name of target */ - public void taskStarted( String taskName ) + public void taskStarted( final String taskName ) { + m_taskName = taskName; + for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].taskStarted( taskName ); + m_listeners[ i ].taskStarted( this ); } } @@ -131,8 +155,10 @@ public class ProjectListenerSupport { for( int i = 0; i < m_listeners.length; i++ ) { - m_listeners[ i ].taskFinished(); + m_listeners[ i ].taskFinished( this ); } + + m_taskName = null; } /** @@ -140,25 +166,62 @@ public class ProjectListenerSupport * * @param message the log message */ - public void log( String message ) + public void log( String message, Throwable throwable ) { - for( int i = 0; i < m_listeners.length; i++ ) + m_message = message; + m_throwable = throwable; + + try + { + for( int i = 0; i < m_listeners.length; i++ ) + { + m_listeners[ i ].log( this ); + } + } + finally { - m_listeners[ i ].log( message ); + m_message = null; + m_throwable = null; } } /** - * Fire a log event. - * - * @param message the log message - * @param throwable the throwable to be logged + * Returns the message. */ - public void log( String message, Throwable throwable ) + public String getMessage() { - for( int i = 0; i < m_listeners.length; i++ ) - { - m_listeners[ i ].log( message, throwable ); - } + return m_message; + } + + /** + * Returns the error that occurred. + */ + public Throwable getThrowable() + { + return m_throwable; + } + + /** + * Returns the name of the task. + */ + public String getTaskName() + { + return m_taskName; + } + + /** + * Returns the name of the target. + */ + public String getTargetName() + { + return m_targetName; + } + + /** + * Returns the name of the project. + */ + public String getProjectName() + { + return m_projectName; } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java b/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java index baaf70d5b..38c2d38f4 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java @@ -61,6 +61,7 @@ public class CLIMain private final static int LOG_LEVEL_OPT = 'l'; private final static int DEFINE_OPT = 'D'; private final static int BUILDER_PARAM_OPT = 'B'; + private final static int NO_PREFIX_OPT = 'p'; private final static int VERSION_OPT = 1; private final static int LISTENER_OPT = 2; private final static int TASKLIB_DIR_OPT = 5; @@ -72,8 +73,9 @@ public class CLIMain private final static int[] INFO_OPT_INCOMPAT = new int[] { HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT, - LOG_LEVEL_OPT, VERSION_OPT, LISTENER_OPT, - DEFINE_OPT, DRY_RUN_OPT //TASKLIB_DIR_OPT, HOME_DIR_OPT + LOG_LEVEL_OPT, BUILDER_PARAM_OPT, NO_PREFIX_OPT, + VERSION_OPT, LISTENER_OPT, TASKLIB_DIR_OPT, + INCREMENTAL_OPT, HOME_DIR_OPT, DRY_RUN_OPT }; //incompatable options for other logging options @@ -82,6 +84,12 @@ public class CLIMain QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT }; + //incompatible options for listener options + private final static int[] LISTENER_OPT_INCOMPAT = new int[] + { + LISTENER_OPT, NO_PREFIX_OPT + }; + ///Parameters for run of myrmidon private Parameters m_parameters = new Parameters(); @@ -138,79 +146,73 @@ public class CLIMain private CLOptionDescriptor[] createCLOptions() { //TODO: localise - final CLOptionDescriptor[] options = new CLOptionDescriptor[ 13 ]; - options[ 0 ] = + final CLOptionDescriptor[] options = { new CLOptionDescriptor( "help", CLOptionDescriptor.ARGUMENT_DISALLOWED, HELP_OPT, REZ.getString( "help.opt" ), - INFO_OPT_INCOMPAT ); - options[ 1 ] = + INFO_OPT_INCOMPAT ), new CLOptionDescriptor( "file", CLOptionDescriptor.ARGUMENT_REQUIRED, FILE_OPT, - REZ.getString( "file.opt" ) ); - options[ 2 ] = + REZ.getString( "file.opt" ) ), new CLOptionDescriptor( "log-level", CLOptionDescriptor.ARGUMENT_REQUIRED, LOG_LEVEL_OPT, REZ.getString( "log-level.opt" ), - LOG_OPT_INCOMPAT ); - options[ 3 ] = + LOG_OPT_INCOMPAT ), new CLOptionDescriptor( "quiet", CLOptionDescriptor.ARGUMENT_DISALLOWED, QUIET_OPT, REZ.getString( "quiet.opt" ), - LOG_OPT_INCOMPAT ); - options[ 4 ] = + LOG_OPT_INCOMPAT ), new CLOptionDescriptor( "verbose", CLOptionDescriptor.ARGUMENT_DISALLOWED, VERBOSE_OPT, REZ.getString( "verbose.opt" ), - LOG_OPT_INCOMPAT ); - options[ 5 ] = + LOG_OPT_INCOMPAT ), new CLOptionDescriptor( "listener", CLOptionDescriptor.ARGUMENT_REQUIRED, LISTENER_OPT, - REZ.getString( "listener.opt" ) ); - options[ 6 ] = + REZ.getString( "listener.opt" ), + LISTENER_OPT_INCOMPAT ), + new CLOptionDescriptor( "noprefix", + CLOptionDescriptor.ARGUMENT_DISALLOWED, + NO_PREFIX_OPT, + REZ.getString( "noprefix.opt" ), + LISTENER_OPT_INCOMPAT ), new CLOptionDescriptor( "version", CLOptionDescriptor.ARGUMENT_DISALLOWED, VERSION_OPT, REZ.getString( "version.opt" ), - INFO_OPT_INCOMPAT ); - - options[ 7 ] = + INFO_OPT_INCOMPAT ), new CLOptionDescriptor( "task-lib-dir", CLOptionDescriptor.ARGUMENT_REQUIRED, TASKLIB_DIR_OPT, - REZ.getString( "tasklib.opt" ) ); - options[ 8 ] = + REZ.getString( "tasklib.opt" ) ), new CLOptionDescriptor( "incremental", CLOptionDescriptor.ARGUMENT_DISALLOWED, INCREMENTAL_OPT, - REZ.getString( "incremental.opt" ) ); - options[ 9 ] = + REZ.getString( "incremental.opt" ) ), new CLOptionDescriptor( "ant-home", CLOptionDescriptor.ARGUMENT_REQUIRED, HOME_DIR_OPT, - REZ.getString( "home.opt" ) ); - options[ 10 ] = + REZ.getString( "home.opt" ) ), new CLOptionDescriptor( "define", CLOptionDescriptor.ARGUMENTS_REQUIRED_2, DEFINE_OPT, REZ.getString( "define.opt" ), - new int[ 0 ] ); - options[ 11 ] = + new int[ 0 ] ), new CLOptionDescriptor( "builder-parameter", CLOptionDescriptor.ARGUMENTS_REQUIRED_2, BUILDER_PARAM_OPT, - REZ.getString( "build.opt" ) ); - options[ 12 ] = + REZ.getString( "build.opt" ) ), new CLOptionDescriptor( "dry-run", CLOptionDescriptor.ARGUMENT_DISALLOWED, DRY_RUN_OPT, - REZ.getString( "dry-run.opt" ) ); + REZ.getString( "dry-run.opt" ) ) + }; + return options; } @@ -266,9 +268,13 @@ public class CLIMain case FILE_OPT: m_parameters.setParameter( "filename", option.getArgument() ); break; + case LISTENER_OPT: m_parameters.setParameter( "listener", option.getArgument() ); break; + case NO_PREFIX_OPT: + m_parameters.setParameter( "listener", "noprefix" ); + break; case DEFINE_OPT: m_defines.setParameter( option.getArgument( 0 ), option.getArgument( 1 ) ); @@ -298,7 +304,7 @@ public class CLIMain m_parameters.setParameter( "filename", "build.ant" ); m_parameters.setParameter( "log.level", "WARN" ); - m_parameters.setParameter( "listener", "org.apache.myrmidon.listeners.DefaultProjectListener" ); + m_parameters.setParameter( "listener", "default" ); m_parameters.setParameter( "incremental", "false" ); } @@ -332,10 +338,6 @@ public class CLIMain throw new Exception( message ); } - //handle listener.. - final String listenerName = m_parameters.getParameter( "listener", null ); - final ProjectListener listener = createListener( listenerName ); - if( getLogger().isInfoEnabled() ) { final String message = REZ.getString( "buildfile.notice", buildFile ); @@ -363,6 +365,10 @@ public class CLIMain embeddor.initialize(); embeddor.start(); + //create the listener + final String listenerName = m_parameters.getParameter( "listener", null ); + final ProjectListener listener = embeddor.createListener( listenerName ); + //create the project final Project project = embeddor.createProject( buildFile.toString(), null, m_builderParameters ); @@ -415,7 +421,7 @@ public class CLIMain /** * Actually do the build. * - * @param manager the manager + * @param workspace the workspace * @param project the project * @param targets the targets to build as passed by CLI */ @@ -477,27 +483,4 @@ public class CLIMain return logger; } - - /** - * Setup project listener. - * - * @param listener the classname of project listener - */ - private ProjectListener createListener( final String listener ) - throws Exception - { - try - { - return (ProjectListener)Class.forName( listener ).newInstance(); - } - catch( final Throwable t ) - { - final String message = - REZ.getString( "bad-listener.error", - listener, - ExceptionUtil.printStackTrace( t, 5, true ) ); - throw new Exception( message ); - } - } } - diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/Resources.properties index fc568ac5b..636236f8e 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/Resources.properties @@ -3,9 +3,10 @@ error-message=Error: {0}. help.opt=Display this help message. file.opt=Specify the build file. log-level.opt=Specify the verbosity level at which to log messages. (DEBUG|INFO|WARN|ERROR|FATAL_ERROR). -quiet.opt=Equivelent to --log-level=FATAL_ERROR. -verbose.opt=Equivelent to --log-level=INFO. +quiet.opt=Equivalent to --log-level=FATAL_ERROR. +verbose.opt=Equivalent to --log-level=INFO. listener.opt=Specify the listener for log events. +noprefix.opt=Do not prefix output with the task name. Equivalent to --listener noprefix. version.opt=Display version. tasklib.opt=Specify the task lib directory to scan for .tsk files. incremental.opt=Run in incremental mode. @@ -16,7 +17,6 @@ dry-run.opt=Do not execute tasks - just print them out. home-not-dir.error=myrmidon-home ({0}) is not a directory. bad-file.error=File {0} is not a file or doesn't exist. -bad-listener.error=Error creating the listener {0}. Reason: {1}. bad-loglevel.error=Unknown log level - {0}. build-failed.error=BUILD FAILED\nReason:\n{0} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java index 2658fe0f2..763307d38 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java @@ -15,6 +15,7 @@ import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.Parameters; import org.apache.myrmidon.interfaces.model.Project; import org.apache.myrmidon.interfaces.workspace.Workspace; +import org.apache.myrmidon.listeners.ProjectListener; /** * Interface through which you embed Myrmidon into applications. @@ -28,17 +29,30 @@ public interface Embeddor String ROLE = Embeddor.class.getName(); /** - * Create a project. + * Creates a project from a project file. * + * @param location The path to the project file. + * @param type The project file type. If null the type is inferred from the + * project file name. + * @param parameters The project builder parameters. * @return the created Project */ Project createProject( String location, String type, Parameters parameters ) throws Exception; /** - * Create a Workspace for a particular project. + * Creates a project listener. * - * @param defines the defines in workspace + * @param name The shorthand name of the listener. + * @return the listener. + */ + ProjectListener createListener( String name ) + throws Exception; + + /** + * Creates a {@link Workspace} that can be used to execute projects. + * + * @param parameters The properties to define in the workspace * @return the Workspace */ Workspace createWorkspace( Parameters parameters ) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java index f4371746f..39ef851a6 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java @@ -42,7 +42,6 @@ public interface Workspace * * @param project the Project * @param target the name of the target - * @param defines the defines * @exception TaskException if an error occurs */ void executeProject( Project project, String target ) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java index d247341b5..05865a2c8 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java @@ -8,7 +8,8 @@ package org.apache.myrmidon.listeners; /** - * Abstract listener from which to extend. + * Abstract listener from which to extend. This implementation provedes + * empty implementions of each of the event methods. * * @author Peter Donald * @version $Revision$ $Date$ @@ -16,98 +17,52 @@ package org.apache.myrmidon.listeners; public abstract class AbstractProjectListener implements ProjectListener { - /** - * This contains the name of the current target. - */ - private String m_target; - - /** - * This contains the name of the current task. - */ - private String m_task; - /** * Notify listener of projectStarted event. */ - public void projectStarted() + public void projectStarted( final ProjectEvent event ) { } /** * Notify listener of projectFinished event. */ - public void projectFinished() + public void projectFinished( final ProjectEvent event ) { } /** * Notify listener of targetStarted event. - * - * @param targetName the name of target */ - public void targetStarted( final String target ) + public void targetStarted( final TargetEvent event ) { - m_target = target; } /** * Notify listener of targetFinished event. */ - public void targetFinished() + public void targetFinished( final TargetEvent event ) { - m_target = null; } /** * Notify listener of taskStarted event. - * - * @param task the name of task */ - public void taskStarted( final String task ) + public void taskStarted( final TaskEvent event ) { - m_task = task; } /** * Notify listener of taskFinished event. */ - public void taskFinished() - { - m_task = null; - } - - /** - * Notify listener of log message event. - * - * @param message the message - */ - public void log( String message ) + public void taskFinished( final TaskEvent event ) { } /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable - */ - public void log( String message, Throwable throwable ) - { - } - - /** - * Utility method to get the name of current target. - */ - protected final String getTarget() - { - return m_target; - } - - /** - * Utility method to get the name of current task. */ - protected final String getTask() + public void log( final LogEvent event ) { - return m_task; } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java index d53603c50..56d069d31 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java @@ -8,63 +8,93 @@ package org.apache.myrmidon.listeners; import org.apache.avalon.framework.ExceptionUtil; +import java.io.PrintWriter; /** - * Classic listener that emulates the default ant1.x listener notifications. + * Classic listener that emulates the default ant1.x listener. * * @author Peter Donald * @version $Revision$ $Date$ */ -public final class ClassicProjectListener +public class ClassicProjectListener extends AbstractProjectListener { + private final PrintWriter m_printWriter; + + public ClassicProjectListener() + { + m_printWriter = new PrintWriter( System.out, true ); + } + /** * Notify listener of targetStarted event. - * - * @param target the name of target */ - public void targetStarted( final String target ) + public void targetStarted( final TargetEvent event ) { - output( target + ":\n" ); + writeTargetHeader( event ); } /** - * Notify listener of log message event. - * - * @param message the message + * Notify listener of targetFinished event. */ - public void log( String message ) + public void targetFinished( TargetEvent event ) { - output( message ); + getWriter().println(); } /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable */ - public void log( String message, Throwable throwable ) + public void log( final LogEvent event ) + { + writeMessage( event ); + writeThrowable( event ); + } + + /** + * Returns the PrintWriter to write to. + */ + protected PrintWriter getWriter() + { + return m_printWriter; + } + + /** + * Writes the target header. + */ + protected void writeTargetHeader( final TargetEvent event ) { - output( message + "\n" + ExceptionUtil.printStackTrace( throwable, 5, true ) ); + getWriter().println( event.getTargetName() + ":" ); } /** - * Utility class to output data. - * Overide in sub-classes to direct to a different destination. - * - * @param data the data + * Writes a message */ - private void output( final String data ) + protected void writeMessage( final LogEvent event ) { - final String task = getTask(); + // Write the message + final String message = event.getMessage(); + final String task = event.getTaskName(); if( null != task ) { - System.out.println( "\t[" + task + "] " + data ); + getWriter().println( "\t[" + task + "] " + message ); } else { - System.out.println( data ); + getWriter().println( message ); + } + } + + /** + * Writes a throwable. + */ + private void writeThrowable( final LogEvent event ) + { + // Write the exception, if any + final Throwable throwable = event.getThrowable(); + if( throwable != null ) + { + getWriter().println( ExceptionUtil.printStackTrace( throwable, 5, true ) ); } } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java index 8b0230138..bdcc7e707 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java @@ -10,70 +10,49 @@ package org.apache.myrmidon.listeners; import org.apache.avalon.framework.ExceptionUtil; /** - * Default listener that emulates the old ant listener notifications. + * Default listener that emulates the Ant 1.x no banner listener. * * @author Peter Donald * @version $Revision$ $Date$ */ -public final class DefaultProjectListener - extends AbstractProjectListener +public class DefaultProjectListener + extends ClassicProjectListener { private boolean m_targetOutput; /** * Notify listener of targetStarted event. - * - * @param target the name of target */ - public void targetStarted( final String target ) + public void targetStarted( final TargetEvent target ) { - super.targetStarted( target ); m_targetOutput = false; } /** - * Notify listener of log message event. - * - * @param message the message + * Notify listener of targetFinished event. */ - public void log( final String message ) + public void targetFinished( final TargetEvent event ) { - output( message ); + if( m_targetOutput ) + { + getWriter().println(); + } } /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable - */ - public void log( final String message, final Throwable throwable ) - { - output( message + "\n" + ExceptionUtil.printStackTrace( throwable, 5, true ) ); - } - - /** - * Utility class to output data. - * Overide in sub-classes to direct to a different destination. - * - * @param data the data */ - private void output( final String data ) + public void log( final LogEvent event ) { - if( !m_targetOutput ) + // Write the target header, if necessary + final String target = event.getTargetName(); + if( target != null && !m_targetOutput ) { - System.out.println( getTarget() + ":\n" ); + writeTargetHeader( event ); m_targetOutput = true; } - final String task = getTask(); - if( null != task ) - { - System.out.println( "\t[" + task + "] " + data ); - } - else - { - System.out.println( data ); - } + // Write the message + super.log( event ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java new file mode 100644 index 000000000..a401603d6 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java @@ -0,0 +1,28 @@ +/* + * 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.myrmidon.listeners; + +/** + * A log message event. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public interface LogEvent + extends TaskEvent +{ + /** + * Returns the message. + */ + public String getMessage(); + + /** + * Returns the error that occurred. + */ + public Throwable getThrowable(); +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java new file mode 100644 index 000000000..18cbbe184 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java @@ -0,0 +1,29 @@ +/* + * 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.myrmidon.listeners; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * A project listener that emulated the Ant 1.x -emacs mode. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public class NoPrefixProjectListener + extends DefaultProjectListener +{ + /** + * Writes a message + */ + protected void writeMessage( LogEvent event ) + { + getWriter().println( event.getMessage() ); + } +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java new file mode 100644 index 000000000..4d27649e9 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java @@ -0,0 +1,24 @@ +/* + * 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.myrmidon.listeners; + +import org.apache.myrmidon.interfaces.model.Project; + +/** + * A project level event. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public interface ProjectEvent +{ + /** + * Returns the name of the project. + */ + public String getProjectName(); +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java index f57728977..71ade4eb4 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java @@ -18,51 +18,43 @@ package org.apache.myrmidon.listeners; public interface ProjectListener { /** - * Notify listener of projectStarted event. + * Notify the listener that a project is about to start. This method + * is called for top-level projects only. */ - void projectStarted(); + void projectStarted( ProjectEvent event ); /** - * Notify listener of projectFinished event. + * Notify the listener that a project has finished. This method is called + * for top-level projects only. */ - void projectFinished(); + void projectFinished( ProjectEvent event ); /** - * Notify listener of targetStarted event. - * - * @param target the name of target + * Notify the listener that a target is about to start. Note that the + * project name reported by the event may be different to that reported + * in {@link #projectStarted}. */ - void targetStarted( String target ); + void targetStarted( TargetEvent event ); /** - * Notify listener of targetFinished event. + * Notify the listener that a target has finished. */ - void targetFinished(); + void targetFinished( TargetEvent event ); /** - * Notify listener of taskStarted event. - * - * @param task the name of task + * Notify the listener that a task is about to start. */ - void taskStarted( String task ); + void taskStarted( TaskEvent event ); /** - * Notify listener of taskFinished event. + * Notify the listener that a task has finished. */ - void taskFinished(); + void taskFinished( TaskEvent event ); /** - * Notify listener of log message event. - * - * @param message the message + * Notify listener of log message event. Note that this method may + * be called at any time, so the reported task, target, or project names + * may be null. */ - void log( String message ); - - /** - * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable - */ - void log( String message, Throwable throwable ); + void log( LogEvent event ); } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java new file mode 100644 index 000000000..bf42a7284 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java @@ -0,0 +1,25 @@ +/* + * 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.myrmidon.listeners; + +import org.apache.myrmidon.interfaces.model.Target; + +/** + * A target level event. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public interface TargetEvent + extends ProjectEvent +{ + /** + * Returns the name of the target. + */ + public String getTargetName(); +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java new file mode 100644 index 000000000..3703405c8 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java @@ -0,0 +1,23 @@ +/* + * 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.myrmidon.listeners; + +/** + * A task level event. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public interface TaskEvent + extends TargetEvent +{ + /** + * Returns the name of the task. + */ + public String getTaskName(); +} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java index 15696a622..8800fb765 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java @@ -12,6 +12,10 @@ import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.LogEvent; +import org.apache.myrmidon.listeners.ProjectEvent; +import org.apache.myrmidon.listeners.TargetEvent; +import org.apache.myrmidon.listeners.TaskEvent; import org.apache.tools.ant.Project; /** @@ -46,9 +50,6 @@ public class RecorderEntry private Logger m_logger; - /** - * @param name The name of this recorder (used as the filename). - */ protected RecorderEntry( final PrintStream output ) { m_output = output; @@ -93,7 +94,7 @@ public class RecorderEntry /** * Turns off or on this recorder. * - * @param state true for on, false for off, null for no change. + * @param record true for on, false for off, null for no change. */ public void setRecordState( final boolean record ) { @@ -102,21 +103,48 @@ public class RecorderEntry /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable */ - public void log( final String message, final Throwable throwable ) + public void log( final LogEvent event ) { - m_output.println( StringUtil.LINE_SEPARATOR + "BUILD FAILED" + StringUtil.LINE_SEPARATOR ); - throwable.printStackTrace( m_output ); - finishRecording(); + final Throwable throwable = event.getThrowable(); + if( throwable != null ) + { + m_output.println( StringUtil.LINE_SEPARATOR + "BUILD FAILED" + StringUtil.LINE_SEPARATOR ); + throwable.printStackTrace( m_output ); + finishRecording(); + } + else + { + getLogger().debug( "--- MESSAGE LOGGED" ); + + final StringBuffer sb = new StringBuffer(); + + final String task = event.getTaskName(); + if( task != null ) + { + final String name = "[" + task + "]"; + final int padding = 12 - name.length(); + for( int i = 0; i < padding; i++ ) + { + sb.append( " " ); + } + sb.append( name ); + } + + sb.append( event.getMessage() ); + + //FIXME: Check log level here + if( m_record ) + { + m_output.println( sb.toString() ); + } + } } /** * Notify listener of projectFinished event. */ - public void projectFinished() + public void projectFinished( final ProjectEvent event ) { m_output.println( StringUtil.LINE_SEPARATOR + "BUILD SUCCESSFUL" ); finishRecording(); @@ -132,88 +160,49 @@ public class RecorderEntry /** * Notify listener of projectStarted event. */ - public void projectStarted() + public void projectStarted( final ProjectEvent event ) { getLogger().debug( "> BUILD STARTED" ); } - /** - * Notify listener of log message event. - * - * @param message the message - */ - public void log( final String message ) - { - getLogger().debug( "--- MESSAGE LOGGED" ); - - final StringBuffer sb = new StringBuffer(); - - final String task = getTask(); - if( task != null ) - { - final String name = "[" + task + "]"; - final int padding = 12 - name.length(); - for( int i = 0; i < padding; i++ ) - { - sb.append( " " ); - } - sb.append( name ); - } - - sb.append( message ); - - //FIXME: Check log level here - if( m_record ) - { - m_output.println( sb.toString() ); - } - } /** * Notify listener of targetFinished event. */ - public void targetFinished() + public void targetFinished( final TargetEvent event ) { - getLogger().debug( "<< TARGET FINISHED -- " + getTarget() ); + getLogger().debug( "<< TARGET FINISHED -- " + event.getTargetName() ); final long millis = System.currentTimeMillis() - m_targetStartTime; final String duration = formatTime( millis ); - getLogger().debug( getTarget() + ": duration " + duration ); + getLogger().debug( event.getTargetName() + ": duration " + duration ); m_output.flush(); - super.targetFinished(); } /** * Notify listener of targetStarted event. - * - * @param target the name of target */ - public void targetStarted( final String target ) + public void targetStarted( final TargetEvent event ) { - super.targetStarted( target ); - getLogger().debug( ">> TARGET STARTED -- " + getTarget() ); - getLogger().info( StringUtil.LINE_SEPARATOR + getTarget() + ":" ); + getLogger().debug( ">> TARGET STARTED -- " + event.getTargetName() ); + getLogger().info( StringUtil.LINE_SEPARATOR + event.getTargetName() + ":" ); m_targetStartTime = System.currentTimeMillis(); } /** * Notify listener of taskStarted event. - * - * @param task the name of task */ - public void taskStarted( String task ) + public void taskStarted( final TaskEvent event ) { - super.taskStarted( task ); - getLogger().debug( ">>> TASK STARTED -- " + getTask() ); + getLogger().debug( ">>> TASK STARTED -- " + event.getTaskName() ); } /** * Notify listener of taskFinished event. */ - public void taskFinished() + public void taskFinished( final TaskEvent event ) { - getLogger().debug( "<<< TASK FINISHED -- " + getTask() ); + getLogger().debug( "<<< TASK FINISHED -- " + event.getTaskName() ); m_output.flush(); - super.taskFinished(); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java index df60608bc..23f050573 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java @@ -16,6 +16,7 @@ import java.util.Date; import java.util.Properties; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.LogEvent; import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.taskdefs.MatchingTask; @@ -1067,10 +1068,8 @@ public class IContract extends MatchingTask { /** * Notify listener of log message event. - * - * @param message the message */ - public void log( final String message ) + public void log( final LogEvent event ) { if( "java.lang.NoClassDefFoundError: com/reliablesystems/iContract/Tool".equals( event.getMessage() ) ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java index de0654476..6fd956083 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java @@ -22,6 +22,8 @@ import javax.sound.sampled.UnsupportedAudioFileException; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.ProjectEvent; +import org.apache.myrmidon.listeners.LogEvent; /** * This class is designed to be used by any AntTask that requires audio output. @@ -65,20 +67,20 @@ public class AntSoundPlayer /** * Notify listener of projectFinished event. */ - public void projectFinished() + public void projectFinished( final ProjectEvent event ) { success(); } /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable */ - public void log( final String message, final Throwable throwable ) + public void log( final LogEvent event ) { - failure(); + if( event.getThrowable() != null ) + { + failure(); + } } /** diff --git a/proposal/myrmidon/src/manifest/builtin-ant-descriptor.xml b/proposal/myrmidon/src/manifest/builtin-ant-descriptor.xml index 90eec58f9..b375e5cce 100644 --- a/proposal/myrmidon/src/manifest/builtin-ant-descriptor.xml +++ b/proposal/myrmidon/src/manifest/builtin-ant-descriptor.xml @@ -4,6 +4,7 @@ + diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/RecorderEntry.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/RecorderEntry.java index 15696a622..8800fb765 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/RecorderEntry.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/RecorderEntry.java @@ -12,6 +12,10 @@ import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.LogEvent; +import org.apache.myrmidon.listeners.ProjectEvent; +import org.apache.myrmidon.listeners.TargetEvent; +import org.apache.myrmidon.listeners.TaskEvent; import org.apache.tools.ant.Project; /** @@ -46,9 +50,6 @@ public class RecorderEntry private Logger m_logger; - /** - * @param name The name of this recorder (used as the filename). - */ protected RecorderEntry( final PrintStream output ) { m_output = output; @@ -93,7 +94,7 @@ public class RecorderEntry /** * Turns off or on this recorder. * - * @param state true for on, false for off, null for no change. + * @param record true for on, false for off, null for no change. */ public void setRecordState( final boolean record ) { @@ -102,21 +103,48 @@ public class RecorderEntry /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable */ - public void log( final String message, final Throwable throwable ) + public void log( final LogEvent event ) { - m_output.println( StringUtil.LINE_SEPARATOR + "BUILD FAILED" + StringUtil.LINE_SEPARATOR ); - throwable.printStackTrace( m_output ); - finishRecording(); + final Throwable throwable = event.getThrowable(); + if( throwable != null ) + { + m_output.println( StringUtil.LINE_SEPARATOR + "BUILD FAILED" + StringUtil.LINE_SEPARATOR ); + throwable.printStackTrace( m_output ); + finishRecording(); + } + else + { + getLogger().debug( "--- MESSAGE LOGGED" ); + + final StringBuffer sb = new StringBuffer(); + + final String task = event.getTaskName(); + if( task != null ) + { + final String name = "[" + task + "]"; + final int padding = 12 - name.length(); + for( int i = 0; i < padding; i++ ) + { + sb.append( " " ); + } + sb.append( name ); + } + + sb.append( event.getMessage() ); + + //FIXME: Check log level here + if( m_record ) + { + m_output.println( sb.toString() ); + } + } } /** * Notify listener of projectFinished event. */ - public void projectFinished() + public void projectFinished( final ProjectEvent event ) { m_output.println( StringUtil.LINE_SEPARATOR + "BUILD SUCCESSFUL" ); finishRecording(); @@ -132,88 +160,49 @@ public class RecorderEntry /** * Notify listener of projectStarted event. */ - public void projectStarted() + public void projectStarted( final ProjectEvent event ) { getLogger().debug( "> BUILD STARTED" ); } - /** - * Notify listener of log message event. - * - * @param message the message - */ - public void log( final String message ) - { - getLogger().debug( "--- MESSAGE LOGGED" ); - - final StringBuffer sb = new StringBuffer(); - - final String task = getTask(); - if( task != null ) - { - final String name = "[" + task + "]"; - final int padding = 12 - name.length(); - for( int i = 0; i < padding; i++ ) - { - sb.append( " " ); - } - sb.append( name ); - } - - sb.append( message ); - - //FIXME: Check log level here - if( m_record ) - { - m_output.println( sb.toString() ); - } - } /** * Notify listener of targetFinished event. */ - public void targetFinished() + public void targetFinished( final TargetEvent event ) { - getLogger().debug( "<< TARGET FINISHED -- " + getTarget() ); + getLogger().debug( "<< TARGET FINISHED -- " + event.getTargetName() ); final long millis = System.currentTimeMillis() - m_targetStartTime; final String duration = formatTime( millis ); - getLogger().debug( getTarget() + ": duration " + duration ); + getLogger().debug( event.getTargetName() + ": duration " + duration ); m_output.flush(); - super.targetFinished(); } /** * Notify listener of targetStarted event. - * - * @param target the name of target */ - public void targetStarted( final String target ) + public void targetStarted( final TargetEvent event ) { - super.targetStarted( target ); - getLogger().debug( ">> TARGET STARTED -- " + getTarget() ); - getLogger().info( StringUtil.LINE_SEPARATOR + getTarget() + ":" ); + getLogger().debug( ">> TARGET STARTED -- " + event.getTargetName() ); + getLogger().info( StringUtil.LINE_SEPARATOR + event.getTargetName() + ":" ); m_targetStartTime = System.currentTimeMillis(); } /** * Notify listener of taskStarted event. - * - * @param task the name of task */ - public void taskStarted( String task ) + public void taskStarted( final TaskEvent event ) { - super.taskStarted( task ); - getLogger().debug( ">>> TASK STARTED -- " + getTask() ); + getLogger().debug( ">>> TASK STARTED -- " + event.getTaskName() ); } /** * Notify listener of taskFinished event. */ - public void taskFinished() + public void taskFinished( final TaskEvent event ) { - getLogger().debug( "<<< TASK FINISHED -- " + getTask() ); + getLogger().debug( "<<< TASK FINISHED -- " + event.getTaskName() ); m_output.flush(); - super.taskFinished(); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java index df60608bc..23f050573 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java @@ -16,6 +16,7 @@ import java.util.Date; import java.util.Properties; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.LogEvent; import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.taskdefs.MatchingTask; @@ -1067,10 +1068,8 @@ public class IContract extends MatchingTask { /** * Notify listener of log message event. - * - * @param message the message */ - public void log( final String message ) + public void log( final LogEvent event ) { if( "java.lang.NoClassDefFoundError: com/reliablesystems/iContract/Tool".equals( event.getMessage() ) ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java index de0654476..6fd956083 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java @@ -22,6 +22,8 @@ import javax.sound.sampled.UnsupportedAudioFileException; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.listeners.AbstractProjectListener; +import org.apache.myrmidon.listeners.ProjectEvent; +import org.apache.myrmidon.listeners.LogEvent; /** * This class is designed to be used by any AntTask that requires audio output. @@ -65,20 +67,20 @@ public class AntSoundPlayer /** * Notify listener of projectFinished event. */ - public void projectFinished() + public void projectFinished( final ProjectEvent event ) { success(); } /** * Notify listener of log message event. - * - * @param message the message - * @param throwable the throwable */ - public void log( final String message, final Throwable throwable ) + public void log( final LogEvent event ) { - failure(); + if( event.getThrowable() != null ) + { + failure(); + } } /**