mirror of https://github.com/apache/maven.git
o create a new dispatcher on every invocation
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
def783e4cf
commit
027453d5b1
|
@ -38,7 +38,7 @@ public class Plugin
|
||||||
|
|
||||||
System.out.println( "<<<<<<<<<<<<<<<<<<<<<<<<<");
|
System.out.println( "<<<<<<<<<<<<<<<<<<<<<<<<<");
|
||||||
|
|
||||||
maven.execute( pom, Collections.singletonList( "package" ), eventMonitor, new ConsoleDownloadMonitor(), targetDirectory );
|
maven.execute( pom, Collections.singletonList( "package" ), eventMonitor, new ConsoleDownloadMonitor(), null, targetDirectory );
|
||||||
|
|
||||||
System.out.println( "<<<<<<<<<<<<<<<<<<<<<<<<<");
|
System.out.println( "<<<<<<<<<<<<<<<<<<<<<<<<<");
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class intended to be used by clients who wish to embed Maven into their applications
|
* Class intended to be used by clients who wish to embed Maven into their applications
|
||||||
|
@ -108,8 +109,6 @@ public class MavenEmbedder
|
||||||
|
|
||||||
private PluginDescriptorBuilder pluginDescriptorBuilder;
|
private PluginDescriptorBuilder pluginDescriptorBuilder;
|
||||||
|
|
||||||
private EventDispatcher eventDispatcher;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Configuration
|
// Configuration
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -372,21 +371,25 @@ public class MavenEmbedder
|
||||||
List goals,
|
List goals,
|
||||||
EventMonitor eventMonitor,
|
EventMonitor eventMonitor,
|
||||||
TransferListener transferListener,
|
TransferListener transferListener,
|
||||||
|
Properties properties,
|
||||||
File executionRootDirectory )
|
File executionRootDirectory )
|
||||||
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
||||||
{
|
{
|
||||||
execute( Collections.singletonList( project ), goals, eventMonitor, transferListener, executionRootDirectory );
|
execute( Collections.singletonList( project ), goals, eventMonitor, transferListener, properties, executionRootDirectory );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute( List projects,
|
public void execute( List projects,
|
||||||
List goals,
|
List goals,
|
||||||
EventMonitor eventMonitor,
|
EventMonitor eventMonitor,
|
||||||
TransferListener transferListener,
|
TransferListener transferListener,
|
||||||
|
Properties properties,
|
||||||
File executionRootDirectory )
|
File executionRootDirectory )
|
||||||
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException
|
||||||
{
|
{
|
||||||
ReactorManager rm = new ReactorManager( projects );
|
ReactorManager rm = new ReactorManager( projects );
|
||||||
|
|
||||||
|
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
||||||
|
|
||||||
eventDispatcher.addEventMonitor( eventMonitor );
|
eventDispatcher.addEventMonitor( eventMonitor );
|
||||||
|
|
||||||
rm.setFailureBehavior( ReactorManager.FAIL_AT_END );
|
rm.setFailureBehavior( ReactorManager.FAIL_AT_END );
|
||||||
|
@ -406,6 +409,25 @@ public class MavenEmbedder
|
||||||
wagonManager.setDownloadMonitor( transferListener );
|
wagonManager.setDownloadMonitor( transferListener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Maven should not be using system properties internally but because
|
||||||
|
// it does for now I'll just take properties that are handed to me
|
||||||
|
// and set them so that the plugin expression evaluator will work
|
||||||
|
// as expected.
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( properties != null )
|
||||||
|
{
|
||||||
|
for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
String key = (String) i.next();
|
||||||
|
|
||||||
|
String value = properties.getProperty( key );
|
||||||
|
|
||||||
|
System.setProperty( key, value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MavenExecutionResponse response = lifecycleExecutor.execute( session,
|
MavenExecutionResponse response = lifecycleExecutor.execute( session,
|
||||||
rm,
|
rm,
|
||||||
session.getEventDispatcher() );
|
session.getEventDispatcher() );
|
||||||
|
@ -575,8 +597,6 @@ public class MavenEmbedder
|
||||||
|
|
||||||
pluginDescriptorBuilder = new PluginDescriptorBuilder();
|
pluginDescriptorBuilder = new PluginDescriptorBuilder();
|
||||||
|
|
||||||
eventDispatcher = new DefaultEventDispatcher();
|
|
||||||
|
|
||||||
profileManager = new DefaultProfileManager( embedder.getContainer() );
|
profileManager = new DefaultProfileManager( embedder.getContainer() );
|
||||||
|
|
||||||
mavenProjectBuilder = (MavenProjectBuilder) embedder.lookup( MavenProjectBuilder.ROLE );
|
mavenProjectBuilder = (MavenProjectBuilder) embedder.lookup( MavenProjectBuilder.ROLE );
|
||||||
|
|
|
@ -8,13 +8,12 @@ import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||||
import org.apache.maven.monitor.event.EventMonitor;
|
import org.apache.maven.monitor.event.EventMonitor;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
|
||||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MavenEmbedderTest
|
public class MavenEmbedderTest
|
||||||
|
@ -75,7 +74,12 @@ public class MavenEmbedderTest
|
||||||
|
|
||||||
EventMonitor eventMonitor = new DefaultEventMonitor( new PlexusLoggerAdapter( new MavenEmbedderConsoleLogger() ) );
|
EventMonitor eventMonitor = new DefaultEventMonitor( new PlexusLoggerAdapter( new MavenEmbedderConsoleLogger() ) );
|
||||||
|
|
||||||
maven.execute( pom, Collections.singletonList( "package" ), eventMonitor, new ConsoleDownloadMonitor(), targetDirectory );
|
maven.execute( pom,
|
||||||
|
Collections.singletonList( "package" ),
|
||||||
|
eventMonitor,
|
||||||
|
new ConsoleDownloadMonitor(),
|
||||||
|
null,
|
||||||
|
targetDirectory );
|
||||||
|
|
||||||
File jar = new File( targetDirectory, "target/embedder-test-project-1.0-SNAPSHOT.jar" );
|
File jar = new File( targetDirectory, "target/embedder-test-project-1.0-SNAPSHOT.jar" );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue