mirror of https://github.com/apache/maven.git
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:
parent
1e33cb56fe
commit
a0d6f81a20
|
@ -78,16 +78,13 @@ public class DefaultMaven
|
||||||
|
|
||||||
private void fireEvent( MavenSession session, ExecutionEventCatapult catapult )
|
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 );
|
ExecutionEvent event = new DefaultLifecycleEvent( session, null );
|
||||||
|
|
||||||
for ( ExecutionListener listener : listeners )
|
catapult.fire( listener, event );
|
||||||
{
|
|
||||||
catapult.fire( listener, event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class DefaultMavenExecutionRequest
|
||||||
|
|
||||||
private List<ArtifactRepository> pluginArtifactRepositories;
|
private List<ArtifactRepository> pluginArtifactRepositories;
|
||||||
|
|
||||||
private List<ExecutionListener> lifecycleListeners;
|
private ExecutionListener executionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suppress SNAPSHOT updates.
|
* Suppress SNAPSHOT updates.
|
||||||
|
@ -163,7 +163,7 @@ public class DefaultMavenExecutionRequest
|
||||||
copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
|
copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
|
||||||
copy.setRepositoryCache( original.getRepositoryCache() );
|
copy.setRepositoryCache( original.getRepositoryCache() );
|
||||||
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
|
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
|
||||||
copy.setExecutionListeners( original.getExecutionListeners() );
|
copy.setExecutionListener( original.getExecutionListener() );
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,26 +944,14 @@ public class DefaultMavenExecutionRequest
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExecutionListener> getExecutionListeners()
|
public ExecutionListener getExecutionListener()
|
||||||
{
|
{
|
||||||
if ( lifecycleListeners == null )
|
return executionListener;
|
||||||
{
|
|
||||||
lifecycleListeners = new ArrayList<ExecutionListener>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return lifecycleListeners;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenExecutionRequest setExecutionListeners( List<ExecutionListener> lifecycleListeners )
|
public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener )
|
||||||
{
|
{
|
||||||
if ( lifecycleListeners != null )
|
this.executionListener = executionListener;
|
||||||
{
|
|
||||||
this.lifecycleListeners = new ArrayList<ExecutionListener>( lifecycleListeners );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.lifecycleListeners = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,8 +263,8 @@ public interface MavenExecutionRequest
|
||||||
File getUserToolchainsFile();
|
File getUserToolchainsFile();
|
||||||
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
||||||
|
|
||||||
List<ExecutionListener> getExecutionListeners();
|
ExecutionListener getExecutionListener();
|
||||||
MavenExecutionRequest setExecutionListeners( List<ExecutionListener> executionListeners );
|
MavenExecutionRequest setExecutionListener( ExecutionListener executionListener );
|
||||||
|
|
||||||
ProjectBuildingRequest getProjectBuildingRequest();
|
ProjectBuildingRequest getProjectBuildingRequest();
|
||||||
|
|
||||||
|
|
|
@ -140,16 +140,13 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private void fireEvent( MavenSession session, MojoExecution mojoExecution, LifecycleEventCatapult catapult )
|
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 );
|
ExecutionEvent event = new DefaultLifecycleEvent( session, mojoExecution );
|
||||||
|
|
||||||
for ( ExecutionListener listener : listeners )
|
catapult.fire( listener, event );
|
||||||
{
|
|
||||||
catapult.fire( listener, event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ package org.apache.maven.cli;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.ParseException;
|
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.MavenEmbedderFileLogger;
|
||||||
import org.apache.maven.embedder.MavenEmbedderLogger;
|
import org.apache.maven.embedder.MavenEmbedderLogger;
|
||||||
import org.apache.maven.exception.ExceptionSummary;
|
import org.apache.maven.exception.ExceptionSummary;
|
||||||
import org.apache.maven.execution.ExecutionListener;
|
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResult;
|
import org.apache.maven.execution.MavenExecutionResult;
|
||||||
import org.codehaus.plexus.classworlds.ClassWorld;
|
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||||
|
@ -122,7 +120,7 @@ public class MavenCli
|
||||||
|
|
||||||
MavenEmbedderLogger logger = configuration.getMavenEmbedderLogger();
|
MavenEmbedderLogger logger = configuration.getMavenEmbedderLogger();
|
||||||
|
|
||||||
request.setExecutionListeners( Arrays.<ExecutionListener> asList( new ExecutionEventLogger( logger ) ) );
|
request.setExecutionListener( new ExecutionEventLogger( logger ) );
|
||||||
|
|
||||||
if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
|
if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue