mirror of https://github.com/apache/maven.git
o removing MavenProject from the public signature of the plugin manager to enforce the concern of the plugin manager which is simply to execute plugins. all configuration and processing of configuration happens before the plugin manager. the only thing left is the expression evaluator which has the mixed concern of configuration and componnent injection.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@774361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
861244fe51
commit
d13f1295b7
|
@ -445,7 +445,7 @@ public class DefaultLifecycleExecutor
|
|||
// Maven plugin deployment we will find the right PluginDescriptor from the remote
|
||||
// repository.
|
||||
|
||||
plugin = pluginManager.findPluginForPrefix( prefix, project );
|
||||
plugin = pluginManager.findPluginForPrefix( prefix, localRepository, project.getRemoteArtifactRepositories() );
|
||||
|
||||
// Search plugin in the current POM
|
||||
if ( plugin == null )
|
||||
|
@ -456,7 +456,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
try
|
||||
{
|
||||
desc = pluginManager.loadPlugin( buildPlugin, project, localRepository );
|
||||
desc = pluginManager.loadPlugin( buildPlugin, localRepository, project.getRemoteArtifactRepositories() );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
|
@ -505,7 +505,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
try
|
||||
{
|
||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, project, localRepository );
|
||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, project.getRemoteArtifactRepositories() );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
|
@ -530,7 +530,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
try
|
||||
{
|
||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, project, localRepository );
|
||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, project.getRemoteArtifactRepositories() );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
// This should be template method code for allowing subclasses to assist in contributing search/hint information
|
||||
public Plugin findPluginForPrefix( String prefix, MavenProject project )
|
||||
public Plugin findPluginForPrefix( String prefix, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
//Use the plugin managers capabilities to get information to augement the request
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class DefaultPluginManager
|
|||
//return getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() );
|
||||
}
|
||||
|
||||
public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, ArtifactRepository localRepository )
|
||||
public PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
|
||||
|
@ -136,7 +136,7 @@ public class DefaultPluginManager
|
|||
|
||||
try
|
||||
{
|
||||
return addPlugin( plugin, project, localRepository );
|
||||
return addPlugin( plugin, localRepository, remoteRepositories );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
// PluginResolutionException - a problem that occurs resolving the plugin artifact or its deps
|
||||
|
@ -167,7 +167,7 @@ public class DefaultPluginManager
|
|||
return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion();
|
||||
}
|
||||
|
||||
protected PluginDescriptor addPlugin( Plugin plugin, MavenProject project, ArtifactRepository localRepository )
|
||||
protected PluginDescriptor addPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactNotFoundException, ArtifactResolutionException, PluginVersionResolutionException, PluginContainerException, PluginVersionNotFoundException
|
||||
{
|
||||
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
|
||||
|
@ -175,7 +175,7 @@ public class DefaultPluginManager
|
|||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( pluginArtifact )
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() );
|
||||
.setRemoteRepostories( remoteRepositories );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class DefaultPluginManager
|
|||
|
||||
ClassRealm pluginRealm = container.createChildRealm( pluginKey( plugin ) );
|
||||
|
||||
Set<Artifact> pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, project, localRepository );
|
||||
Set<Artifact> pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository, remoteRepositories );
|
||||
|
||||
for ( Artifact a : pluginArtifacts )
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ public class DefaultPluginManager
|
|||
// its dependencies while filtering out what's in the core
|
||||
// layering on the project level plugin dependencies
|
||||
|
||||
private Set<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedinPom, MavenProject project, ArtifactRepository localRepository )
|
||||
private Set<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedinPom, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactNotFoundException, ArtifactResolutionException
|
||||
{
|
||||
AndArtifactFilter filter = new AndArtifactFilter();
|
||||
|
@ -260,7 +260,7 @@ public class DefaultPluginManager
|
|||
// So this in fact are overrides ...
|
||||
.setArtifactDependencies( dependenciesToResolveForPlugin )
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setRemoteRepostories( remoteRepositories )
|
||||
.setFilter( filter )
|
||||
.setResolveTransitively( true );
|
||||
|
||||
|
@ -536,10 +536,10 @@ public class DefaultPluginManager
|
|||
}
|
||||
}
|
||||
|
||||
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, MavenProject project, ArtifactRepository localRepository )
|
||||
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, project, localRepository );
|
||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, localRepository, remoteRepositories );
|
||||
|
||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||
|
||||
|
|
|
@ -15,12 +15,13 @@ package org.apache.maven.plugin;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.component.discovery.ComponentDiscoverer;
|
||||
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
|
||||
|
||||
|
@ -35,12 +36,12 @@ public interface PluginManager
|
|||
// - configure the plugin [extension point]
|
||||
// - execute the plugin
|
||||
|
||||
Plugin findPluginForPrefix( String prefix, MavenProject project );
|
||||
Plugin findPluginForPrefix( String prefix, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories );
|
||||
|
||||
PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, ArtifactRepository localRepository )
|
||||
PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginLoaderException;
|
||||
|
||||
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, MavenProject project, ArtifactRepository localRepository )
|
||||
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginLoaderException;
|
||||
|
||||
void executeMojo( MavenSession session, MojoExecution execution )
|
||||
|
|
|
@ -6,6 +6,7 @@ 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;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
public class PluginManagerTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
|
@ -77,10 +78,16 @@ public class PluginManagerTest
|
|||
public void testRemoteResourcesPlugin()
|
||||
throws Exception
|
||||
{
|
||||
//TODO: turn an equivalent back on when the RR plugin is released.
|
||||
|
||||
/*
|
||||
|
||||
This will not work until the RR plugin is released to get rid of the binding to the reporting exception which is a mistake.
|
||||
|
||||
This happpens after removing the reporting API from the core:
|
||||
|
||||
java.lang.NoClassDefFoundError: org/apache/maven/reporting/MavenReportException
|
||||
|
||||
MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) );
|
||||
String goal = "process";
|
||||
|
||||
|
@ -107,9 +114,14 @@ public class PluginManagerTest
|
|||
plugin.setArtifactId( "maven-surefire-plugin" );
|
||||
plugin.setVersion( "2.4.2" );
|
||||
|
||||
// The project has already been fully interpolated so getting the raw mojoDescriptor is not going to have the processes configuration.
|
||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject(), session.getLocalRepository() );
|
||||
assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-surefire-plugin", "2.4.2" );
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
|
||||
|
||||
System.out.println( session.getCurrentProject().getBuild().getPluginsAsMap() );
|
||||
|
||||
Xpp3Dom configuration = (Xpp3Dom) session.getCurrentProject().getBuild().getPluginsAsMap().get( plugin.getKey() ).getExecutions().get( 0 ).getConfiguration();
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, configuration );
|
||||
pluginManager.executeMojo( session, mojoExecution );
|
||||
}
|
||||
|
||||
|
|
|
@ -1457,8 +1457,7 @@ public class PomConstructionTest
|
|||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
|
||||
String localRepoUrl =
|
||||
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||
String localRepoUrl = System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||
localRepoUrl = "file://" + localRepoUrl;
|
||||
config.setLocalRepository( new DefaultArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout() ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue