Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 39557 invoked from network); 18 May 2002 04:19:49 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 18 May 2002 04:19:49 -0000 Received: (qmail 26387 invoked by uid 97); 18 May 2002 04:19:51 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 26364 invoked by uid 97); 18 May 2002 04:19:51 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 26336 invoked by uid 97); 18 May 2002 04:19:50 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 18 May 2002 04:19:35 -0000 Message-ID: <20020518041935.6418.qmail@icarus.apache.org> From: adammurdoch@apache.org To: jakarta-ant-myrmidon-cvs@apache.org Subject: cvs commit: jakarta-ant-myrmidon/site/src/xdocs todo.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N adammurdoch 02/05/17 21:19:35 Modified: antlib/src/java/org/apache/antlib/sound AntSoundPlayer.java SoundTask.java api/src/java/org/apache/myrmidon/api/event TaskListener.java framework/src/todo/org/apache/tools/todo/taskdefs IContract.java site/src/xdocs todo.xml Added: antlib/src/java/org/apache/antlib/project ClassicProjectListener.java DefaultProjectListener.java NoPrefixProjectListener.java framework/src/java/org/apache/myrmidon/framework/listener AbstractProjectListener.java ProjectEvent.java ProjectListener.java ProjectListenerDeployer.java TaskToProjectListenerAdapter.java Removed: api/src/java/org/apache/myrmidon/listeners AbstractProjectListener.java ClassicProjectListener.java DefaultProjectListener.java NoPrefixProjectListener.java ProjectEvent.java ProjectListener.java TaskToProjectListenerAdapter.java Log: Moved ProjectListener out of task API: * Moved ProjectListener, ProjectEvent, and AbstractProjectListener to framework. * Moved concrete implementations to project antlib. * Added a custom deployer for project listeners, which registers them under ProjectListener and TaskListener roles. Revision Changes Path 1.1 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/ClassicProjectListener.java Index: ClassicProjectListener.java =================================================================== /* * 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.project; import java.io.PrintWriter; import org.apache.avalon.framework.ExceptionUtil; import org.apache.myrmidon.framework.listener.AbstractProjectListener; import org.apache.myrmidon.framework.listener.ProjectEvent; /** * Classic listener that emulates the default ant1.x listener. * * @author Peter Donald * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ * @ant.type type="project-listener" name="classic" */ public class ClassicProjectListener extends AbstractProjectListener { private final PrintWriter m_printWriter; public ClassicProjectListener() { m_printWriter = new PrintWriter( System.out, true ); } /** * Notify listener of targetStarted event. */ public void targetStarted( final ProjectEvent event ) { writeTargetHeader( event ); } /** * Notify listener of targetFinished event. */ public void targetFinished( final ProjectEvent event ) { getWriter().println(); } /** * Notify listener of log message event. */ public void log( final ProjectEvent 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 ProjectEvent event ) { getWriter().println( event.getTarget() + ":" ); } /** * Writes a message */ protected void writeMessage( final ProjectEvent event ) { // Write the message final String message = event.getMessage(); final String task = event.getTask(); if( null != task ) { getWriter().println( " [" + task + "] " + message ); } else { getWriter().println( message ); } } /** * Writes a throwable. */ private void writeThrowable( final ProjectEvent event ) { // Write the exception, if any final Throwable throwable = event.getThrowable(); if( throwable != null ) { getWriter().println( ExceptionUtil.printStackTrace( throwable, 8, true ) ); } } } 1.1 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/DefaultProjectListener.java Index: DefaultProjectListener.java =================================================================== /* * 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.project; import org.apache.antlib.project.ClassicProjectListener; import org.apache.myrmidon.framework.listener.ProjectEvent; /** * Default listener that emulates the Ant 1.x no banner listener. * * @author Peter Donald * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ * @ant.type type="project-listener" name="default" */ public class DefaultProjectListener extends ClassicProjectListener { private boolean m_targetOutput; /** * Notify listener of targetStarted event. */ public void targetStarted( final ProjectEvent target ) { m_targetOutput = false; } /** * Notify listener of targetFinished event. */ public void targetFinished( final ProjectEvent event ) { if( m_targetOutput ) { getWriter().println(); } } /** * Notify listener of log message event. */ public void log( final ProjectEvent event ) { // Write the target header, if necessary final String target = event.getTarget(); if( target != null && !m_targetOutput ) { writeTargetHeader( event ); m_targetOutput = true; } // Write the message super.log( event ); } } 1.1 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/NoPrefixProjectListener.java Index: NoPrefixProjectListener.java =================================================================== /* * 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.project; import org.apache.antlib.project.DefaultProjectListener; import org.apache.myrmidon.framework.listener.ProjectEvent; /** * A project listener that emulated the Ant 1.x -emacs mode. * * @author Adam Murdoch * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ * @ant.type type="project-listener" name="noprefix" */ public class NoPrefixProjectListener extends DefaultProjectListener { /** * Writes a message */ protected void writeMessage( final ProjectEvent event ) { getWriter().println( event.getMessage() ); } } 1.3 +3 -3 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/sound/AntSoundPlayer.java Index: AntSoundPlayer.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/sound/AntSoundPlayer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AntSoundPlayer.java 25 Apr 2002 08:17:31 -0000 1.2 +++ AntSoundPlayer.java 18 May 2002 04:19:34 -0000 1.3 @@ -21,8 +21,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.framework.listener.AbstractProjectListener; +import org.apache.myrmidon.framework.listener.ProjectEvent; /** * This class is designed to be used by any AntTask that requires audio output. @@ -32,7 +32,7 @@ * Both seem to work fine. * * @author Nick Pellow - * @version $Revision: 1.2 $, $Date: 2002/04/25 08:17:31 $ + * @version $Revision: 1.3 $, $Date: 2002/05/18 04:19:34 $ */ public class AntSoundPlayer extends AbstractProjectListener 1.3 +2 -2 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/sound/SoundTask.java Index: SoundTask.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/sound/SoundTask.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SoundTask.java 11 May 2002 12:44:00 -0000 1.2 +++ SoundTask.java 18 May 2002 04:19:34 -0000 1.3 @@ -15,7 +15,7 @@ import org.apache.myrmidon.api.AbstractTask; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.interfaces.workspace.Workspace; -import org.apache.myrmidon.listeners.TaskToProjectListenerAdapter; +import org.apache.myrmidon.framework.listener.TaskToProjectListenerAdapter; /** * This is an example of an AntTask that makes of use of the AntSoundPlayer. @@ -30,7 +30,7 @@ * @ant.task name="sound-listener" * @author Nick Pellow * @author Peter Donald - * @version $Revision: 1.2 $, $Date: 2002/05/11 12:44:00 $ + * @version $Revision: 1.3 $, $Date: 2002/05/18 04:19:34 $ */ public class SoundTask extends AbstractTask 1.4 +3 -1 jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/event/TaskListener.java Index: TaskListener.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/event/TaskListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TaskListener.java 25 Apr 2002 08:25:24 -0000 1.3 +++ TaskListener.java 18 May 2002 04:19:34 -0000 1.4 @@ -12,11 +12,13 @@ * notifications about tasks. * * @author Peter Donald - * @version $Revision: 1.3 $ $Date: 2002/04/25 08:25:24 $ + * @version $Revision: 1.4 $ $Date: 2002/05/18 04:19:34 $ * @ant.role name="task-listener" */ public interface TaskListener { + String ROLE = "task-listener"; + /** * Notify the listener that the task is starting. * This is called prior to task starting. 1.1 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/AbstractProjectListener.java Index: AbstractProjectListener.java =================================================================== /* * 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.framework.listener; /** * Abstract listener from which to extend. This implementation provedes * empty implementions of each of the event methods. * * @author Peter Donald * @author Adam Murdoch * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ */ public abstract class AbstractProjectListener implements ProjectListener { /** * Notify listener of projectStarted event. */ public void projectStarted( final ProjectEvent event ) { } /** * Notify listener of projectFinished event. */ public void projectFinished( final ProjectEvent event ) { } /** * Notify listener of targetStarted event. */ public void targetStarted( final ProjectEvent event ) { } /** * Notify listener of targetFinished event. */ public void targetFinished( final ProjectEvent event ) { } /** * Notify listener of taskStarted event. */ public void taskStarted( final ProjectEvent event ) { } /** * Notify listener of taskFinished event. */ public void taskFinished( final ProjectEvent event ) { } /** * Notify listener of log message event. */ public void log( final ProjectEvent event ) { } } 1.1 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectEvent.java Index: ProjectEvent.java =================================================================== /* * 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.framework.listener; import java.util.EventObject; import org.apache.myrmidon.api.event.TaskEvent; /** * An event raised while processing an Ant project. * * @author Adam Murdoch * @author Peter Donald * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ */ public class ProjectEvent extends EventObject { /** * The name of the project associated with event. */ private final String m_projectName; /** * The name of the target associated with event (if any). */ private final String m_targetName; /** * The name of the task associated with event (if any). */ private final String m_taskName; /** * Message associated with event. */ private final String m_message; /** * Exception associated with event */ private final Throwable m_throwable; public ProjectEvent( final TaskEvent source, final String projectName, final String targetName, final String taskName, final String message, final Throwable throwable ) { super( source ); m_projectName = projectName; m_targetName = targetName; m_taskName = taskName; m_message = message; m_throwable = throwable; } public String getProject() { return m_projectName; } public String getTarget() { return m_targetName; } public String getTask() { return m_taskName; } public String getMessage() { return m_message; } public Throwable getThrowable() { return m_throwable; } public TaskEvent getTaskEvent() { return (TaskEvent)getSource(); } } 1.1 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListener.java Index: ProjectListener.java =================================================================== /* * 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.framework.listener; import org.apache.myrmidon.framework.listener.ProjectEvent; /** * The interface to implement if you want to receive * notification of project status. * * @author Peter Donald * @author Adam Murdoch * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ * @ant.role name="project-listener" * type-deployer="org.apache.myrmidon.framework.listener.ProjectListenerDeployer" * * @todo Think about having a way to indicate that a foreign project * is being referenced, a implicit target is being referenced * and that a library is being imported. */ public interface ProjectListener { String ROLE = "listener"; /** * Notify the listener that a project is about to start. This method * is called for top-level projects only. */ void projectStarted( ProjectEvent event ); /** * Notify the listener that a project has finished. This method is called * for top-level projects only. */ void projectFinished( ProjectEvent event ); /** * 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( ProjectEvent event ); /** * Notify the listener that a target has finished. */ void targetFinished( ProjectEvent event ); /** * Notify the listener that a task is about to start. */ void taskStarted( ProjectEvent event ); /** * Notify the listener that a task has finished. */ void taskFinished( ProjectEvent event ); /** * 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( ProjectEvent event ); } 1.1 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListenerDeployer.java Index: ProjectListenerDeployer.java =================================================================== /* * 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.framework.listener; import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer; import org.apache.myrmidon.interfaces.deployer.TypeDefinition; import org.apache.myrmidon.interfaces.type.TypeFactory; import org.apache.myrmidon.interfaces.type.AdaptingTypeFactory; import org.apache.myrmidon.api.event.TaskListener; /** * A deployer for project listeners. Registers the listener as a * ProjectListener, and a TaskListener. * * @author Adam Murdoch * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ */ public class ProjectListenerDeployer extends DefaultTypeDeployer { private final AdaptingTypeFactory m_factory = new AdaptingTypeFactory( TaskToProjectListenerAdapter.class ); /** * Deploys a type. */ public void deployType( final String namespace, final TypeDefinition typeDefinition, final TypeFactory typeFactory ) throws Exception { // Register the listener as a ProjectListener super.deployType( namespace, typeDefinition, typeFactory ); // Register the listener as a TaskListener final String typeName = typeDefinition.getName(); m_factory.addMapping( typeName, typeFactory ); getTypeManager().registerType( TaskListener.ROLE, namespace, typeDefinition.getName(), m_factory ); } } 1.1 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/TaskToProjectListenerAdapter.java Index: TaskToProjectListenerAdapter.java =================================================================== /* * 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.framework.listener; import java.util.StringTokenizer; import org.apache.myrmidon.api.event.TaskEvent; import org.apache.myrmidon.api.event.TaskListener; import org.apache.myrmidon.framework.listener.ProjectEvent; import org.apache.myrmidon.framework.listener.ProjectListener; /** * This is a class that adapts {@link org.apache.myrmidon.api.event.TaskListener} interface to * the {@link org.apache.myrmidon.framework.listener.ProjectListener} interface. * * @author Peter Donald * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $ */ public class TaskToProjectListenerAdapter implements TaskListener { private final ProjectListener m_listener; /** * Create an adaptor for specified listener. * * @param listener the ProjectListener to redirect events to */ public TaskToProjectListenerAdapter( final ProjectListener listener ) { m_listener = listener; } /** * Notify the listener that the task is starting. * This is called prior to task starting. * * @param event the TaskEvent */ public void taskStarting( final TaskEvent event ) { final ProjectEvent projectEvent = toProjectEvent( event ); if( null == projectEvent.getTarget() ) { m_listener.projectStarted( projectEvent ); } else if( null == projectEvent.getTask() ) { m_listener.targetStarted( projectEvent ); } else { m_listener.taskStarted( projectEvent ); } } /** * Notify the listener that the task logged * a message. * * @param event the TaskEvent */ public void taskMessage( final TaskEvent event ) { final ProjectEvent projectEvent = toProjectEvent( event ); m_listener.log( projectEvent ); } /** * Notify the listener that the task has finished. * This is called after task has finished. * * @param event the TaskEvent */ public void taskFinished( final TaskEvent event ) { final ProjectEvent projectEvent = toProjectEvent( event ); if( null == projectEvent.getTarget() ) { m_listener.projectFinished( projectEvent ); } else if( null == projectEvent.getTask() ) { m_listener.targetFinished( projectEvent ); } else { m_listener.taskFinished( projectEvent ); } } /** * Convert the specified {@link org.apache.myrmidon.api.event.TaskEvent} to a {@link org.apache.myrmidon.framework.listener.ProjectEvent}. * * @param event the TaskEvent * @return the Project event representing TaskEvent */ private ProjectEvent toProjectEvent( final TaskEvent event ) { final String path = event.getPath(); final String[] elements = split( path, "/" ); String projectName = null; String targetName = null; String taskName = null; if( elements.length >= 1 ) { projectName = elements[ 0 ]; } if( elements.length >= 2 ) { targetName = elements[ 1 ]; } if( elements.length >= 3 ) { taskName = elements[ elements.length - 1 ]; } return new ProjectEvent( event, projectName, targetName, taskName, event.getMessage(), event.getThrowable() ); } /** * Splits the string on every token into an array of strings. * * @param string the string * @param onToken the token * @return the resultant array */ protected final String[] split( final String string, final String onToken ) { final StringTokenizer tokenizer = new StringTokenizer( string, onToken ); final String[] result = new String[ tokenizer.countTokens() ]; for( int i = 0; i < result.length; i++ ) { result[ i ] = tokenizer.nextToken(); } return result; } } 1.3 +1 -1 jakarta-ant-myrmidon/framework/src/todo/org/apache/tools/todo/taskdefs/IContract.java Index: IContract.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/todo/org/apache/tools/todo/taskdefs/IContract.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IContract.java 6 May 2002 09:29:44 -0000 1.2 +++ IContract.java 18 May 2002 04:19:35 -0000 1.3 @@ -15,7 +15,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.framework.listener.AbstractProjectListener; import org.apache.myrmidon.listeners.LogEvent; import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter; import org.apache.tools.todo.taskdefs.javac.Javac; 1.4 +2 -0 jakarta-ant-myrmidon/site/src/xdocs/todo.xml Index: todo.xml =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/site/src/xdocs/todo.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- todo.xml 16 May 2002 01:28:28 -0000 1.3 +++ todo.xml 18 May 2002 04:19:35 -0000 1.4 @@ -298,6 +298,8 @@ <path> or <fileset>) as Ant 1 types. +
  • Add an adaptor to convert an Ant 1 BuildListener to a + TaskListener.
  • Missing tests:
      -- To unsubscribe, e-mail: For additional commands, e-mail: