mirror of https://github.com/apache/maven.git
o get rid of more Settings references beyond the embedder
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@726164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
153e69973d
commit
e02b6e7005
|
@ -293,5 +293,14 @@ public class MavenSession
|
||||||
{
|
{
|
||||||
return request.getProjectBuildingConfiguration();
|
return request.getProjectBuildingConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getPluginGroups()
|
||||||
|
{
|
||||||
|
return request.getPluginGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOffline()
|
||||||
|
{
|
||||||
|
return request.isOffline();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,12 @@ package org.apache.maven.lifecycle;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.apache.maven.AggregatedBuildFailureException;
|
import org.apache.maven.AggregatedBuildFailureException;
|
||||||
import org.apache.maven.BuildFailureException;
|
import org.apache.maven.BuildFailureException;
|
||||||
import org.apache.maven.NoGoalsSpecifiedException;
|
import org.apache.maven.NoGoalsSpecifiedException;
|
||||||
|
@ -48,23 +54,13 @@ import org.apache.maven.plugin.loader.PluginLoader;
|
||||||
import org.apache.maven.plugin.loader.PluginLoaderException;
|
import org.apache.maven.plugin.loader.PluginLoaderException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
|
||||||
import org.codehaus.plexus.PlexusContainer;
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.context.Context;
|
|
||||||
import org.codehaus.plexus.context.ContextException;
|
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for orchestrating the process of building the ordered list of
|
* Responsible for orchestrating the process of building the ordered list of
|
||||||
* steps required to achieve the specified set of tasks passed into Maven, then
|
* steps required to achieve the specified set of tasks passed into Maven, then
|
||||||
|
@ -110,9 +106,7 @@ public class DefaultLifecycleExecutor
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void execute( final MavenSession session,
|
public void execute( MavenSession session, ReactorManager reactorManager, EventDispatcher dispatcher )
|
||||||
final ReactorManager reactorManager,
|
|
||||||
final EventDispatcher dispatcher )
|
|
||||||
throws BuildFailureException, LifecycleExecutionException
|
throws BuildFailureException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
||||||
|
@ -219,27 +213,15 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
if ( !reactorManager.isBlackListed( project ) )
|
if ( !reactorManager.isBlackListed( project ) )
|
||||||
{
|
{
|
||||||
// line();
|
|
||||||
//
|
|
||||||
// getLogger().info( "Building " + project.getName() );
|
|
||||||
//
|
|
||||||
// getLogger().info( " " + segment );
|
|
||||||
//
|
|
||||||
// line();
|
|
||||||
|
|
||||||
String target = project.getName() + "\nId: " + project.getId() + "\n" + segment;
|
String target = project.getName() + "\nId: " + project.getId() + "\n" + segment;
|
||||||
|
|
||||||
getLogger().debug( "Constructing build plan for " + target );
|
getLogger().debug( "Constructing build plan for " + target );
|
||||||
|
|
||||||
// !! This is ripe for refactoring to an aspect.
|
|
||||||
// Event monitoring.
|
|
||||||
String event = MavenEvents.PROJECT_EXECUTION;
|
String event = MavenEvents.PROJECT_EXECUTION;
|
||||||
|
|
||||||
long buildStartTime = System.currentTimeMillis();
|
long buildStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
dispatcher.dispatchStart(
|
dispatcher.dispatchStart( event, target );
|
||||||
event,
|
|
||||||
target );
|
|
||||||
|
|
||||||
ClassRealm oldLookupRealm = setProjectLookupRealm( session, project );
|
ClassRealm oldLookupRealm = setProjectLookupRealm( session, project );
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class DefaultPluginManager
|
||||||
{
|
{
|
||||||
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
||||||
// use for the mapping manager in here
|
// use for the mapping manager in here
|
||||||
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
|
return pluginMappingManager.getByPrefix( prefix, session.getPluginGroups(),
|
||||||
project.getRemoteArtifactRepositories(),
|
project.getRemoteArtifactRepositories(),
|
||||||
session.getLocalRepository() );
|
session.getLocalRepository() );
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ public class DefaultPluginManager
|
||||||
+ ". It requires a project with an existing pom.xml, but the build is not using one." );
|
+ ". It requires a project with an existing pom.xml, but the build is not using one." );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() )
|
if ( mojoDescriptor.isOnlineRequired() && session.isOffline() )
|
||||||
{
|
{
|
||||||
// TODO: Should we error out, or simply warn and skip??
|
// TODO: Should we error out, or simply warn and skip??
|
||||||
throw new PluginExecutionException( mojoExecution, project,
|
throw new PluginExecutionException( mojoExecution, project,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.apache.maven.plugin.PluginManagerSupport;
|
||||||
import org.apache.maven.plugin.PluginMappingManager;
|
import org.apache.maven.plugin.PluginMappingManager;
|
||||||
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.apache.maven.settings.Settings;
|
//import org.apache.maven.settings.Settings;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.LogEnabled;
|
import org.codehaus.plexus.logging.LogEnabled;
|
||||||
|
@ -160,10 +160,8 @@ public class DefaultPluginPrefixLoader
|
||||||
MavenSession session )
|
MavenSession session )
|
||||||
throws PluginLoaderException
|
throws PluginLoaderException
|
||||||
{
|
{
|
||||||
Settings settings = session.getSettings();
|
|
||||||
|
|
||||||
Plugin plugin = pluginMappingManager.getByPrefix( prefix,
|
Plugin plugin = pluginMappingManager.getByPrefix( prefix,
|
||||||
settings.getPluginGroups(),
|
session.getPluginGroups(),
|
||||||
project.getRemoteArtifactRepositories(),
|
project.getRemoteArtifactRepositories(),
|
||||||
session.getLocalRepository() );
|
session.getLocalRepository() );
|
||||||
|
|
||||||
|
|
|
@ -344,18 +344,13 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
throws CycleDetectedException, DuplicateProjectException
|
throws CycleDetectedException, DuplicateProjectException
|
||||||
{
|
{
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||||
.setSettings( new Settings() )
|
|
||||||
.setProperties( new Properties() )
|
.setProperties( new Properties() )
|
||||||
.setStartTime( new Date() )
|
.setStartTime( new Date() )
|
||||||
.setGoals( Collections.EMPTY_LIST )
|
.setGoals( Collections.EMPTY_LIST )
|
||||||
.setBaseDirectory( new File( "" ) )
|
.setBaseDirectory( new File( "" ) )
|
||||||
.setLocalRepository( repo );
|
.setLocalRepository( repo );
|
||||||
|
|
||||||
// return new MavenSession( container, request, new DefaultEventDispatcher(),
|
return new MavenSession( container, request, new DefaultEventDispatcher(), new ReactorManager( Collections.EMPTY_LIST, ReactorManager.FAIL_FAST ) );
|
||||||
// new ReactorManager( Collections.EMPTY_LIST, ReactorManager.FAIL_FAST ), Collections.EMPTY_MAP );
|
|
||||||
|
|
||||||
return new MavenSession( container, request, new DefaultEventDispatcher(),
|
|
||||||
new ReactorManager( Collections.EMPTY_LIST, ReactorManager.FAIL_FAST ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLocalRepositoryExtraction()
|
public void testLocalRepositoryExtraction()
|
||||||
|
|
|
@ -5,13 +5,11 @@ import org.apache.maven.embedder.DefaultConfiguration;
|
||||||
import org.apache.maven.embedder.MavenEmbedderException;
|
import org.apache.maven.embedder.MavenEmbedderException;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.settings.Settings;
|
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
public class DefaultMavenExecutionRequestPopulatorTest
|
public class DefaultMavenExecutionRequestPopulatorTest
|
||||||
extends PlexusTestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
private MavenExecutionRequestPopulator populator;
|
private MavenExecutionRequestPopulator populator;
|
||||||
|
|
||||||
private WagonManager wagonManager;
|
private WagonManager wagonManager;
|
||||||
|
@ -28,10 +26,7 @@ public class DefaultMavenExecutionRequestPopulatorTest
|
||||||
public void testWagonManagerOfflineFlagIsPopulatedFromSettings()
|
public void testWagonManagerOfflineFlagIsPopulatedFromSettings()
|
||||||
throws MavenEmbedderException
|
throws MavenEmbedderException
|
||||||
{
|
{
|
||||||
Settings settings = new Settings();
|
MavenExecutionRequest req = new DefaultMavenExecutionRequest().setOffline( true );
|
||||||
settings.setOffline( true );
|
|
||||||
|
|
||||||
MavenExecutionRequest req = new DefaultMavenExecutionRequest().setSettings( settings );
|
|
||||||
|
|
||||||
assertTrue( wagonManager.isOnline() );
|
assertTrue( wagonManager.isOnline() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue