mirror of https://github.com/apache/maven.git
o adding transfer listener to execution
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292816 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df59dabb75
commit
f96ed8ac07
|
@ -31,7 +31,7 @@ public class Plugin
|
|||
|
||||
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
||||
|
||||
maven.execute( pom, Collections.singletonList( "package" ), eventDispatcher, targetDirectory );
|
||||
maven.execute( pom, Collections.singletonList( "package" ), eventDispatcher, null, targetDirectory );
|
||||
}
|
||||
|
||||
public static void main( String[] args )
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
|||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
|
@ -95,6 +96,8 @@ public class MavenEmbedder
|
|||
|
||||
private LifecycleExecutor lifecycleExecutor;
|
||||
|
||||
private WagonManager wagonManager;
|
||||
|
||||
private MavenXpp3Reader modelReader;
|
||||
|
||||
private MavenXpp3Writer modelWriter;
|
||||
|
@ -346,13 +349,24 @@ public class MavenEmbedder
|
|||
|
||||
// TODO: should we allow the passing in of a settings object so that everything can be taken from the client env
|
||||
|
||||
public void execute( MavenProject project, List goals, EventDispatcher eventDispatcher, File executionRootDirectory )
|
||||
// TODO: transfer listener
|
||||
// TODO: logger
|
||||
|
||||
public void execute( MavenProject project,
|
||||
List goals,
|
||||
EventDispatcher eventDispatcher,
|
||||
TransferListener transferListener,
|
||||
File executionRootDirectory )
|
||||
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
||||
{
|
||||
execute( Collections.singletonList( project ), goals, eventDispatcher, executionRootDirectory );
|
||||
execute( Collections.singletonList( project ), goals, eventDispatcher, transferListener, executionRootDirectory );
|
||||
}
|
||||
|
||||
public void execute( List projects, List goals, EventDispatcher eventDispatcher, File executionRootDirectory )
|
||||
public void execute( List projects,
|
||||
List goals,
|
||||
EventDispatcher eventDispatcher,
|
||||
TransferListener transferListener,
|
||||
File executionRootDirectory )
|
||||
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
||||
{
|
||||
ReactorManager rm = new ReactorManager( projects );
|
||||
|
@ -369,6 +383,11 @@ public class MavenEmbedder
|
|||
|
||||
session.setUsingPOMsFromFilesystem( true );
|
||||
|
||||
if ( transferListener != null )
|
||||
{
|
||||
wagonManager.setDownloadMonitor( transferListener );
|
||||
}
|
||||
|
||||
MavenExecutionResponse response = lifecycleExecutor.execute( session,
|
||||
rm,
|
||||
session.getEventDispatcher() );
|
||||
|
@ -539,6 +558,8 @@ public class MavenEmbedder
|
|||
|
||||
lifecycleExecutor = (LifecycleExecutor) embedder.lookup( LifecycleExecutor.ROLE );
|
||||
|
||||
wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// If an explicit local repository has not been set then we will use the
|
||||
// setting builder to use the maven defaults to help us find one.
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.apache.maven.artifact.Artifact;
|
|||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.cli.ConsoleDownloadMonitor;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -70,7 +71,7 @@ public class MavenEmbedderTest
|
|||
|
||||
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
||||
|
||||
maven.execute( pom, Collections.singletonList( "package" ), eventDispatcher, targetDirectory );
|
||||
maven.execute( pom, Collections.singletonList( "package" ), eventDispatcher, new ConsoleDownloadMonitor(), targetDirectory );
|
||||
|
||||
File jar = new File( targetDirectory, "target/embedder-test-project-1.0-SNAPSHOT.jar" );
|
||||
|
||||
|
|
Loading…
Reference in New Issue