o Simplified code (multi-cast can be realized by a delegating listener if required)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@809402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-30 18:41:45 +00:00
parent 1e33cb56fe
commit a0d6f81a20
5 changed files with 15 additions and 35 deletions

View File

@ -78,18 +78,15 @@ public class DefaultMaven
private void fireEvent( MavenSession session, ExecutionEventCatapult catapult )
{
List<ExecutionListener> listeners = session.getRequest().getExecutionListeners();
ExecutionListener listener = session.getRequest().getExecutionListener();
if ( !listeners.isEmpty() )
if ( listener != null )
{
ExecutionEvent event = new DefaultLifecycleEvent( session, null );
for ( ExecutionListener listener : listeners )
{
catapult.fire( listener, event );
}
}
}
public MavenExecutionResult execute( MavenExecutionRequest request )
{

View File

@ -118,7 +118,7 @@ public class DefaultMavenExecutionRequest
private List<ArtifactRepository> pluginArtifactRepositories;
private List<ExecutionListener> lifecycleListeners;
private ExecutionListener executionListener;
/**
* Suppress SNAPSHOT updates.
@ -163,7 +163,7 @@ public class DefaultMavenExecutionRequest
copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
copy.setRepositoryCache( original.getRepositoryCache() );
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
copy.setExecutionListeners( original.getExecutionListeners() );
copy.setExecutionListener( original.getExecutionListener() );
return original;
}
@ -944,26 +944,14 @@ public class DefaultMavenExecutionRequest
return this;
}
public List<ExecutionListener> getExecutionListeners()
public ExecutionListener getExecutionListener()
{
if ( lifecycleListeners == null )
{
lifecycleListeners = new ArrayList<ExecutionListener>();
return executionListener;
}
return lifecycleListeners;
}
public MavenExecutionRequest setExecutionListeners( List<ExecutionListener> lifecycleListeners )
public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener )
{
if ( lifecycleListeners != null )
{
this.lifecycleListeners = new ArrayList<ExecutionListener>( lifecycleListeners );
}
else
{
this.lifecycleListeners = null;
}
this.executionListener = executionListener;
return this;
}

View File

@ -263,8 +263,8 @@ public interface MavenExecutionRequest
File getUserToolchainsFile();
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
List<ExecutionListener> getExecutionListeners();
MavenExecutionRequest setExecutionListeners( List<ExecutionListener> executionListeners );
ExecutionListener getExecutionListener();
MavenExecutionRequest setExecutionListener( ExecutionListener executionListener );
ProjectBuildingRequest getProjectBuildingRequest();

View File

@ -140,18 +140,15 @@ public class DefaultLifecycleExecutor
private void fireEvent( MavenSession session, MojoExecution mojoExecution, LifecycleEventCatapult catapult )
{
List<ExecutionListener> listeners = session.getRequest().getExecutionListeners();
ExecutionListener listener = session.getRequest().getExecutionListener();
if ( !listeners.isEmpty() )
if ( listener != null )
{
ExecutionEvent event = new DefaultLifecycleEvent( session, mojoExecution );
for ( ExecutionListener listener : listeners )
{
catapult.fire( listener, event );
}
}
}
private static String getKey( MavenProject project )
{

View File

@ -16,7 +16,6 @@ package org.apache.maven.cli;
*/
import java.io.File;
import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
@ -29,7 +28,6 @@ import org.apache.maven.embedder.MavenEmbedderException;
import org.apache.maven.embedder.MavenEmbedderFileLogger;
import org.apache.maven.embedder.MavenEmbedderLogger;
import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.execution.ExecutionListener;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.codehaus.plexus.classworlds.ClassWorld;
@ -122,7 +120,7 @@ public class MavenCli
MavenEmbedderLogger logger = configuration.getMavenEmbedderLogger();
request.setExecutionListeners( Arrays.<ExecutionListener> asList( new ExecutionEventLogger( logger ) ) );
request.setExecutionListener( new ExecutionEventLogger( logger ) );
if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
{