mirror of https://github.com/apache/maven.git
o get rid of dead MavenSession methods
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@759511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6bcb9de387
commit
9ed0e15d31
|
@ -341,7 +341,7 @@ public class DefaultMaven
|
|||
|
||||
protected MavenSession createSession( MavenExecutionRequest request, ReactorManager reactorManager, EventDispatcher dispatcher )
|
||||
{
|
||||
MavenSession session = new MavenSession( container, request, reactorManager, dispatcher );
|
||||
MavenSession session = new MavenSession( container, request );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -91,21 +91,6 @@ public class MavenSession
|
|||
this.eventDispatcher = new DefaultEventDispatcher( request.getEventMonitors() );
|
||||
}
|
||||
|
||||
//TODO: get rid of this
|
||||
public MavenSession( PlexusContainer container, MavenExecutionRequest request, ReactorManager reactorManager )
|
||||
{
|
||||
this.container = container;
|
||||
this.request = request;
|
||||
this.reactorManager = reactorManager;
|
||||
}
|
||||
|
||||
//TODO: get rid of this
|
||||
public MavenSession( PlexusContainer container, MavenExecutionRequest request, ReactorManager reactorManager, EventDispatcher eventdispatcher )
|
||||
{
|
||||
this( container, request, reactorManager );
|
||||
this.eventDispatcher = eventdispatcher;
|
||||
}
|
||||
|
||||
public Map<String,Object> getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project )
|
||||
{
|
||||
if ( reactorManager == null )
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Map;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.maven.BuildFailureException;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
||||
|
@ -318,28 +317,14 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
return lifecyclePlan;
|
||||
}
|
||||
|
||||
//TODO: which form is most useful. passing in string to parse is not really good.
|
||||
|
||||
MojoDescriptor getMojoDescriptor( Artifact pluginArtifact, String goal, MavenSession session, MavenProject project )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, MavenSession session, MavenProject project )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
|
||||
MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
String goal;
|
||||
|
||||
Plugin plugin;
|
||||
|
||||
StringTokenizer tok = new StringTokenizer( task, ":" );
|
||||
|
@ -366,7 +351,16 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
for ( Plugin buildPlugin : project.getBuildPlugins() )
|
||||
{
|
||||
PluginDescriptor desc = loadPlugin( buildPlugin, project, session );
|
||||
PluginDescriptor desc;
|
||||
|
||||
try
|
||||
{
|
||||
desc = pluginManager.loadPlugin( buildPlugin, project, session );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Error loading PluginDescriptor.", e );
|
||||
}
|
||||
|
||||
if ( prefix.equals( desc.getGoalPrefix() ) )
|
||||
{
|
||||
|
@ -408,28 +402,22 @@ public class DefaultLifecycleExecutor
|
|||
project.injectPluginManagementInfo( plugin );
|
||||
}
|
||||
|
||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, project, session );
|
||||
|
||||
// this has been simplified from the old code that injected the plugin management stuff, since
|
||||
// pluginManagement injection is now handled by the project method.
|
||||
project.addPlugin( plugin );
|
||||
|
||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||
MojoDescriptor mojoDescriptor;
|
||||
|
||||
return mojoDescriptor;
|
||||
}
|
||||
|
||||
private PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
return pluginManager.loadPlugin( plugin, project, session );
|
||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||
}
|
||||
throw new LifecycleExecutionException( "Error loading MojoDescriptor.", e );
|
||||
}
|
||||
|
||||
// this has been simplified from the old code that injected the plugin management stuff, since
|
||||
// pluginManagement injection is now handled by the project method.
|
||||
project.addPlugin( plugin );
|
||||
|
||||
return mojoDescriptor;
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
|
|
|
@ -1814,4 +1814,10 @@ public class DefaultPluginManager
|
|||
throw new PluginLoaderException( plugin, "Failed to load plugin. Reason: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, MavenSession session )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
return loadPlugin( plugin, session.getCurrentProject(), session ).getMojo( goal );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
|
@ -40,6 +41,10 @@ public interface PluginManager
|
|||
PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException;
|
||||
|
||||
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, MavenSession session )
|
||||
throws PluginLoaderException;
|
||||
|
||||
//!!jvz The current project is contained in the session
|
||||
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
||||
throws MojoFailureException, PluginExecutionException, PluginConfigurationException;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.maven.wagon.Wagon;
|
|||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
//TODO: use the AbstractCoreMavenComponentTest
|
||||
public class BuildExtensionListenerTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
|
@ -70,7 +71,7 @@ public class BuildExtensionListenerTest
|
|||
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
|
||||
request.setLocalRepositoryPath( new File( System.getProperty( "user.home" ), ".m2/repository" ) );
|
||||
MavenSession session = new MavenSession( getContainer(), request, rm );
|
||||
MavenSession session = new MavenSession( getContainer(), request );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.AbstractCoreMavenComponentTest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.PluginManager;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
@ -26,7 +22,7 @@ public class PluginManagerTest
|
|||
|
||||
protected String getProjectsDirectory()
|
||||
{
|
||||
return "src/test/projects/plugin-manager";
|
||||
return "src/test/projects/lifecycle-executor";
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
@ -44,9 +40,14 @@ public class PluginManagerTest
|
|||
throws Exception
|
||||
{
|
||||
MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) );
|
||||
String pluginArtifactId = "remote-resources";
|
||||
String goal = "process";
|
||||
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() );
|
||||
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setGroupId( "org.apache.maven.plugins" );
|
||||
plugin.setArtifactId( "maven-remote-resources-plugin" );
|
||||
plugin.setVersion( "1.0" );
|
||||
|
||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session );
|
||||
assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-remote-resources-plugin", "1.0" );
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
|
||||
pluginManager.executeMojo( session.getCurrentProject(), mojoExecution, session );
|
||||
|
@ -56,9 +57,14 @@ public class PluginManagerTest
|
|||
throws Exception
|
||||
{
|
||||
MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) );
|
||||
String pluginArtifactId = "surefire";
|
||||
String goal = "test";
|
||||
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() );
|
||||
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setGroupId( "org.apache.maven.plugins" );
|
||||
plugin.setArtifactId( "maven-surefire-plugin" );
|
||||
plugin.setVersion( "2.4.2" );
|
||||
|
||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session );
|
||||
assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-surefire-plugin", "2.4.2" );
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
|
||||
pluginManager.executeMojo( session.getCurrentProject(), mojoExecution, session );
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.apache.maven.execution.MavenSession;
|
|||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -341,8 +340,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
assertEquals( "value", value );
|
||||
}
|
||||
|
||||
private static MavenSession createSession( PlexusContainer container,
|
||||
ArtifactRepository repo )
|
||||
private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo )
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
{
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||
|
@ -352,7 +350,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
.setBaseDirectory( new File( "" ) )
|
||||
.setLocalRepository( repo );
|
||||
|
||||
return new MavenSession( container, request, (List)null );
|
||||
return new MavenSession( container, request );
|
||||
}
|
||||
|
||||
public void testLocalRepositoryExtraction()
|
||||
|
@ -412,9 +410,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
return new MavenProject( new Model() );
|
||||
}
|
||||
|
||||
private ExpressionEvaluator createExpressionEvaluator( MavenProject project,
|
||||
PluginDescriptor pluginDescriptor,
|
||||
Properties executionProperties )
|
||||
private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties )
|
||||
throws Exception
|
||||
{
|
||||
ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" );
|
||||
|
@ -430,8 +426,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
|
||||
MojoExecution mojoExecution = new MojoExecution( mojo );
|
||||
|
||||
return new PluginParameterExpressionEvaluator( session, mojoExecution, null, container.getLogger(), project,
|
||||
executionProperties );
|
||||
return new PluginParameterExpressionEvaluator( session, mojoExecution, null, container.getLogger(), project, executionProperties );
|
||||
}
|
||||
|
||||
protected Artifact createArtifact( String groupId,
|
||||
|
@ -472,7 +467,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
|
||||
MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class );
|
||||
MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock();
|
||||
MavenSession session = new MavenSession( getContainer(), req, rm );
|
||||
MavenSession session = new MavenSession( getContainer(), req );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue