mirror of https://github.com/apache/maven.git
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@497176 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
14272fda01
commit
e2e634d16c
|
@ -54,6 +54,7 @@ public class MavenArtifactFilterManager
|
|||
artifacts.add( "maven-repository-metadata" );
|
||||
artifacts.add( "maven-settings" );
|
||||
artifacts.add( "plexus-container-default" );
|
||||
artifacts.add( "plexus-component-api" );
|
||||
artifacts.add( "plexus-interactivity-api" );
|
||||
artifacts.add( "plexus-utils" );
|
||||
artifacts.add( "wagon-provider-api" );
|
||||
|
|
|
@ -172,7 +172,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
try
|
||||
{
|
||||
Map handlers = findArtifactTypeHandlers( project, session.getSettings(), session.getLocalRepository() );
|
||||
Map handlers = findArtifactTypeHandlers( project, session );
|
||||
|
||||
artifactHandlerManager.addHandlers( handlers );
|
||||
}
|
||||
|
@ -830,8 +830,7 @@ public class DefaultLifecycleExecutor
|
|||
Plugin plugin = new Plugin();
|
||||
plugin.setGroupId( groupId );
|
||||
plugin.setArtifactId( artifactId );
|
||||
lifecyclePluginDescriptor = verifyPlugin( plugin, project, session.getSettings(),
|
||||
session.getLocalRepository() );
|
||||
lifecyclePluginDescriptor = verifyPlugin( plugin, project, session );
|
||||
if ( lifecyclePluginDescriptor == null )
|
||||
{
|
||||
throw new LifecycleExecutionException(
|
||||
|
@ -1045,8 +1044,7 @@ public class DefaultLifecycleExecutor
|
|||
String packaging = project.getPackaging();
|
||||
Map mappings = null;
|
||||
|
||||
LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging,
|
||||
session.getSettings(), session.getLocalRepository() );
|
||||
LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session );
|
||||
if ( m != null )
|
||||
{
|
||||
mappings = m.getPhases( lifecycle.getId() );
|
||||
|
@ -1093,8 +1091,7 @@ public class DefaultLifecycleExecutor
|
|||
String packaging = project.getPackaging();
|
||||
List optionalMojos = null;
|
||||
|
||||
LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session
|
||||
.getSettings(), session.getLocalRepository() );
|
||||
LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session );
|
||||
|
||||
if ( m != null )
|
||||
{
|
||||
|
@ -1123,8 +1120,7 @@ public class DefaultLifecycleExecutor
|
|||
return optionalMojos;
|
||||
}
|
||||
|
||||
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
private Object findExtension( MavenProject project, String role, String roleHint, MavenSession session )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
{
|
||||
Object pluginComponent = null;
|
||||
|
@ -1135,7 +1131,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
if ( plugin.isExtensions() )
|
||||
{
|
||||
verifyPlugin( plugin, project, settings, localRepository );
|
||||
verifyPlugin( plugin, project, session );
|
||||
|
||||
// TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
|
||||
try
|
||||
|
@ -1160,7 +1156,7 @@ public class DefaultLifecycleExecutor
|
|||
* @todo Not particularly happy about this. Would like WagonManager and ArtifactTypeHandlerManager to be able to
|
||||
* lookup directly, or have them passed in
|
||||
*/
|
||||
private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository )
|
||||
private Map findArtifactTypeHandlers( MavenProject project, MavenSession session )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
{
|
||||
Map map = new HashMap();
|
||||
|
@ -1170,7 +1166,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
if ( plugin.isExtensions() )
|
||||
{
|
||||
verifyPlugin( plugin, project, settings, localRepository );
|
||||
verifyPlugin( plugin, project, session );
|
||||
|
||||
// TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
|
||||
try
|
||||
|
@ -1216,7 +1212,7 @@ public class DefaultLifecycleExecutor
|
|||
Settings settings = session.getSettings();
|
||||
|
||||
PluginDescriptor pluginDescriptor =
|
||||
verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() );
|
||||
verifyPlugin( plugin, project, session );
|
||||
|
||||
if ( pluginDescriptor.getMojos() != null && !pluginDescriptor.getMojos().isEmpty() )
|
||||
{
|
||||
|
@ -1244,14 +1240,13 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
}
|
||||
|
||||
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor;
|
||||
try
|
||||
{
|
||||
pluginDescriptor = pluginManager.verifyPlugin( plugin, project, settings, localRepository );
|
||||
pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session );
|
||||
}
|
||||
catch ( PluginManagerException e )
|
||||
{
|
||||
|
@ -1463,8 +1458,8 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
Plugin buildPlugin = (Plugin) i.next();
|
||||
|
||||
PluginDescriptor desc = verifyPlugin( buildPlugin, project, session.getSettings(), session
|
||||
.getLocalRepository() );
|
||||
PluginDescriptor desc = verifyPlugin( buildPlugin, project, session );
|
||||
|
||||
if ( prefix.equals( desc.getGoalPrefix() ) )
|
||||
{
|
||||
plugin = buildPlugin;
|
||||
|
@ -1516,7 +1511,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
if ( pluginDescriptor == null )
|
||||
{
|
||||
pluginDescriptor = verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() );
|
||||
pluginDescriptor = verifyPlugin( plugin, project, session );
|
||||
}
|
||||
|
||||
// this has been simplified from the old code that injected the plugin management stuff, since
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
|
@ -55,10 +54,10 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
|||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
||||
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
|
||||
|
@ -151,8 +150,7 @@ public class DefaultPluginManager
|
|||
|
||||
public PluginDescriptor verifyPlugin( Plugin plugin,
|
||||
MavenProject project,
|
||||
Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
MavenSession session )
|
||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||
PluginVersionNotFoundException
|
||||
|
@ -162,19 +160,21 @@ public class DefaultPluginManager
|
|||
if ( plugin.getVersion() == null )
|
||||
{
|
||||
String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(),
|
||||
project, settings, localRepository );
|
||||
project, session );
|
||||
plugin.setVersion( version );
|
||||
}
|
||||
|
||||
return verifyVersionedPlugin( plugin, project, localRepository );
|
||||
return verifyVersionedPlugin( plugin, project, session );
|
||||
}
|
||||
|
||||
private PluginDescriptor verifyVersionedPlugin( Plugin plugin,
|
||||
MavenProject project,
|
||||
ArtifactRepository localRepository )
|
||||
MavenSession session )
|
||||
throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException,
|
||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException
|
||||
{
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
||||
// FIXME: need to find out how a plugin gets marked as 'installed'
|
||||
// and no ChildContainer exists. The check for that below fixes
|
||||
|
@ -200,7 +200,7 @@ public class DefaultPluginManager
|
|||
|
||||
if ( !pluginCollector.isPluginInstalled( plugin ) )
|
||||
{
|
||||
addPlugin( plugin, pluginArtifact, project, localRepository );
|
||||
addPlugin( plugin, pluginArtifact, project, session );
|
||||
}
|
||||
|
||||
project.addPlugin( plugin );
|
||||
|
@ -265,23 +265,53 @@ public class DefaultPluginManager
|
|||
}
|
||||
}
|
||||
|
||||
ArtifactFilter coreArtifactFilter = MavenArtifactFilterManager.createStandardFilter();
|
||||
|
||||
protected void addPlugin( Plugin plugin,
|
||||
Artifact pluginArtifact,
|
||||
MavenProject project,
|
||||
ArtifactRepository localRepository )
|
||||
throws PluginManagerException, InvalidPluginException
|
||||
MavenSession session )
|
||||
throws ArtifactNotFoundException, ArtifactResolutionException, PluginManagerException, InvalidPluginException
|
||||
{
|
||||
// ----------------------------------------------------------------------------
|
||||
// Get the dependencies for the Plugin
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the only Plugin instance which will have dependencies is the one specified in the project.
|
||||
// We need to look for a Plugin instance there, in case the instance we're using didn't come from
|
||||
// the project.
|
||||
Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() );
|
||||
|
||||
if ( projectPlugin == null )
|
||||
{
|
||||
projectPlugin = plugin;
|
||||
}
|
||||
|
||||
Set artifacts = getPluginArtifacts( pluginArtifact, projectPlugin, project, session );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Realm creation for a plugin
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ClassRealm componentRealm;
|
||||
ClassRealm componentRealm = null;
|
||||
|
||||
try
|
||||
{
|
||||
componentRealm = container.createComponentRealm( plugin.getKey(),
|
||||
Collections.singletonList( pluginArtifact.getFile() ) );
|
||||
List jars = new ArrayList();
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
|
||||
jars.add( artifact.getFile() );
|
||||
}
|
||||
|
||||
jars.add( pluginArtifact.getFile() );
|
||||
|
||||
// Now here we need the artifact coreArtifactFilter stuff
|
||||
|
||||
componentRealm = container.createComponentRealm( plugin.getKey(), jars );
|
||||
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
|
@ -300,39 +330,92 @@ public class DefaultPluginManager
|
|||
"The PluginDescriptor for the plugin " + plugin.getKey() + " was not found" );
|
||||
}
|
||||
|
||||
pluginDescriptor.setClassRealm( componentRealm );
|
||||
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
||||
|
||||
// we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved
|
||||
// later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
|
||||
// transitively resolve its dependencies, and add them to the plugin container...
|
||||
pluginDescriptor.setArtifacts( Collections.singletonList( pluginArtifact ) );
|
||||
//pluginDescriptor.setArtifacts( Collections.singletonList( pluginArtifact ) );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Get the dependencies for the Plugin
|
||||
// ----------------------------------------------------------------------------
|
||||
//pluginDescriptor.setIntroducedDependencyArtifacts( artifacts );
|
||||
|
||||
pluginDescriptor.setArtifacts( new ArrayList( artifacts ) );
|
||||
|
||||
pluginDescriptor.setClassRealm( componentRealm );
|
||||
}
|
||||
|
||||
private Set getPluginArtifacts( Artifact pluginArtifact,
|
||||
Plugin plugin,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
throws InvalidPluginException, ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException
|
||||
{
|
||||
Set artifacts;
|
||||
|
||||
try
|
||||
{
|
||||
// the only Plugin instance which will have dependencies is the one specified in the project.
|
||||
// We need to look for a Plugin instance there, in case the instance we're using didn't come from
|
||||
// the project.
|
||||
Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() );
|
||||
|
||||
if ( projectPlugin == null )
|
||||
{
|
||||
projectPlugin = plugin;
|
||||
}
|
||||
|
||||
//PLXAPI: These need to be discovered!!!!!
|
||||
Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null,
|
||||
null, project );
|
||||
|
||||
pluginDescriptor.setIntroducedDependencyArtifacts( artifacts );
|
||||
artifacts = MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null,
|
||||
coreArtifactFilter, project );
|
||||
}
|
||||
catch ( InvalidDependencyVersionException e )
|
||||
{
|
||||
throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
ResolutionGroup resolutionGroup;
|
||||
|
||||
try
|
||||
{
|
||||
resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository,
|
||||
project.getPluginArtifactRepositories() );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" +
|
||||
pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e );
|
||||
}
|
||||
|
||||
Set dependencies = new HashSet( resolutionGroup.getArtifacts() );
|
||||
|
||||
List repositories = new ArrayList();
|
||||
|
||||
repositories.addAll( resolutionGroup.getResolutionRepositories() );
|
||||
|
||||
repositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
|
||||
localRepository, repositories,
|
||||
artifactMetadataSource,
|
||||
artifactFilter );
|
||||
|
||||
Set resolved = result.getArtifacts();
|
||||
|
||||
for ( Iterator it = resolved.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
if ( !artifact.equals( pluginArtifact ) )
|
||||
{
|
||||
artifact = project.replaceWithActiveArtifact( artifact );
|
||||
}
|
||||
}
|
||||
|
||||
List unresolved = new ArrayList( dependencies );
|
||||
|
||||
unresolved.removeAll( resolved );
|
||||
|
||||
resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() );
|
||||
|
||||
List allResolved = new ArrayList( resolved.size() + unresolved.size() );
|
||||
|
||||
allResolved.addAll( resolved );
|
||||
|
||||
allResolved.addAll( unresolved );
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -378,6 +461,7 @@ public class DefaultPluginManager
|
|||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||
{
|
||||
MavenProject p = (MavenProject) i.next();
|
||||
|
||||
resolveTransitiveDependencies( session, artifactResolver,
|
||||
mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p );
|
||||
}
|
||||
|
@ -428,9 +512,14 @@ public class DefaultPluginManager
|
|||
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
ClassRealm pluginRealm = pluginDescriptor.getClassRealm();
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader( mojoDescriptor.getPluginDescriptor().getClassRealm() );
|
||||
//ClassRealm pluginRealm = container.getComponentRealm( )
|
||||
|
||||
Thread.currentThread().setContextClassLoader( pluginRealm );
|
||||
|
||||
plugin.execute();
|
||||
|
||||
|
@ -485,9 +574,8 @@ public class DefaultPluginManager
|
|||
if ( version == null )
|
||||
{
|
||||
version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(),
|
||||
reportPlugin.getArtifactId(), project,
|
||||
session.getSettings(),
|
||||
session.getLocalRepository() );
|
||||
reportPlugin.getArtifactId(), project, session );
|
||||
|
||||
reportPlugin.setVersion( version );
|
||||
}
|
||||
|
||||
|
@ -497,7 +585,7 @@ public class DefaultPluginManager
|
|||
forLookup.setArtifactId( reportPlugin.getArtifactId() );
|
||||
forLookup.setVersion( version );
|
||||
|
||||
return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() );
|
||||
return verifyVersionedPlugin( forLookup, project, session );
|
||||
}
|
||||
|
||||
private Mojo getConfiguredMojo( MavenSession session,
|
||||
|
@ -515,14 +603,24 @@ public class DefaultPluginManager
|
|||
// if this is the first time this plugin has been used, the plugin's container will only
|
||||
// contain the plugin's artifact in isolation; we need to finish resolving the plugin's
|
||||
// dependencies, and add them to the container.
|
||||
ensurePluginContainerIsComplete( pluginDescriptor, container, project, session );
|
||||
//getPluginArtifacts( pluginDescriptor, container, project, session );
|
||||
|
||||
Mojo plugin;
|
||||
|
||||
try
|
||||
{
|
||||
ClassRealm realm = mojoDescriptor.getPluginDescriptor().getClassRealm();
|
||||
|
||||
// We are forcing the use of the plugin realm for all lookups that might occur during
|
||||
// the lifecycle that is part of the lookup. Here we are specifically trying to keep
|
||||
// lookups that occur in contextualize calls in line with the right realm.
|
||||
|
||||
DefaultPlexusContainer.setLookupRealm( realm );
|
||||
|
||||
plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
||||
|
||||
DefaultPlexusContainer.setLookupRealm( null );
|
||||
|
||||
if ( report && !( plugin instanceof MavenReport ) )
|
||||
{
|
||||
// TODO: the mojoDescriptor should actually capture this information so we don't get this far
|
||||
|
@ -585,85 +683,6 @@ public class DefaultPluginManager
|
|||
return plugin;
|
||||
}
|
||||
|
||||
private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor,
|
||||
PlexusContainer pluginContainer,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
throws ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException
|
||||
{
|
||||
// if the plugin's already been used once, don't re-do this step...
|
||||
// otherwise, we have to finish resolving the plugin's classpath and start the container.
|
||||
if ( pluginDescriptor.getArtifacts() != null && pluginDescriptor.getArtifacts().size() == 1 )
|
||||
{
|
||||
Artifact pluginArtifact = (Artifact) pluginDescriptor.getArtifacts().get( 0 );
|
||||
|
||||
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
||||
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
ResolutionGroup resolutionGroup;
|
||||
try
|
||||
{
|
||||
resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository,
|
||||
project.getPluginArtifactRepositories() );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" +
|
||||
pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e );
|
||||
}
|
||||
|
||||
Set dependencies = new HashSet( resolutionGroup.getArtifacts() );
|
||||
dependencies.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() );
|
||||
|
||||
List repositories = new ArrayList();
|
||||
repositories.addAll( resolutionGroup.getResolutionRepositories() );
|
||||
repositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
|
||||
localRepository, repositories,
|
||||
artifactMetadataSource,
|
||||
artifactFilter );
|
||||
|
||||
Set resolved = result.getArtifacts();
|
||||
|
||||
for ( Iterator it = resolved.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
if ( !artifact.equals( pluginArtifact ) )
|
||||
{
|
||||
artifact = project.replaceWithActiveArtifact( artifact );
|
||||
|
||||
try
|
||||
{
|
||||
pluginContainer.addJarResource( artifact.getFile() );
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new PluginManagerException( "Error adding plugin dependency '" +
|
||||
artifact.getDependencyConflictId() + "' into plugin manager: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginDescriptor.setClassRealm( pluginContainer.getContainerRealm() );
|
||||
|
||||
List unresolved = new ArrayList( dependencies );
|
||||
|
||||
unresolved.removeAll( resolved );
|
||||
|
||||
resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() );
|
||||
|
||||
List allResolved = new ArrayList( resolved.size() + unresolved.size() );
|
||||
|
||||
allResolved.addAll( resolved );
|
||||
allResolved.addAll( unresolved );
|
||||
|
||||
pluginDescriptor.setArtifacts( allResolved );
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveCoreArtifacts( List unresolved,
|
||||
ArtifactRepository localRepository,
|
||||
List resolutionRepositories )
|
||||
|
@ -1043,6 +1062,8 @@ public class DefaultPluginManager
|
|||
{
|
||||
ComponentConfigurator configurator = null;
|
||||
|
||||
ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm();
|
||||
|
||||
try
|
||||
{
|
||||
String configuratorId = mojoDescriptor.getComponentConfigurator();
|
||||
|
@ -1064,8 +1085,7 @@ public class DefaultPluginManager
|
|||
getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" );
|
||||
|
||||
// This needs to be able to use methods
|
||||
configurator.configureComponent( plugin, configuration, expressionEvaluator,
|
||||
pluginContainer.getContainerRealm(), listener );
|
||||
configurator.configureComponent( plugin, configuration, expressionEvaluator, pluginRealm, listener );
|
||||
|
||||
getLogger().debug( "-- end configuration --" );
|
||||
}
|
||||
|
|
|
@ -54,8 +54,7 @@ public interface PluginManager
|
|||
|
||||
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project );
|
||||
|
||||
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||
PluginVersionNotFoundException;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
|||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.execution.RuntimeInformation;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.plugin.InvalidPluginException;
|
||||
|
@ -80,24 +81,35 @@ public class DefaultPluginVersionManager
|
|||
// TODO: Revisit to remove this piece of state. PLUGIN REGISTRY MAY BE UPDATED ON DISK OUT-OF-PROCESS!
|
||||
private Map resolvedMetaVersions = new HashMap();
|
||||
|
||||
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
public String resolvePluginVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false );
|
||||
return resolvePluginVersion( groupId, artifactId, project, session, false );
|
||||
}
|
||||
|
||||
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
|
||||
Settings settings, ArtifactRepository localRepository )
|
||||
public String resolveReportPluginVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, true );
|
||||
return resolvePluginVersion( groupId, artifactId, project, session, true );
|
||||
}
|
||||
|
||||
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository, boolean resolveAsReportPlugin )
|
||||
private String resolvePluginVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
MavenSession session,
|
||||
boolean resolveAsReportPlugin )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
Settings settings = session.getSettings();
|
||||
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
||||
|
||||
|
@ -302,7 +314,8 @@ public class DefaultPluginVersionManager
|
|||
return version;
|
||||
}
|
||||
|
||||
private boolean shouldCheckForUpdates( String groupId, String artifactId )
|
||||
private boolean shouldCheckForUpdates( String groupId,
|
||||
String artifactId )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId );
|
||||
|
@ -343,7 +356,9 @@ public class DefaultPluginVersionManager
|
|||
}
|
||||
}
|
||||
|
||||
private boolean checkForRejectedStatus( String groupId, String artifactId, String version )
|
||||
private boolean checkForRejectedStatus( String groupId,
|
||||
String artifactId,
|
||||
String version )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId );
|
||||
|
@ -353,8 +368,11 @@ public class DefaultPluginVersionManager
|
|||
return plugin.getRejectedVersions().contains( version );
|
||||
}
|
||||
|
||||
private boolean promptToPersistPluginUpdate( String version, String updatedVersion, String groupId,
|
||||
String artifactId, Settings settings )
|
||||
private boolean promptToPersistPluginUpdate( String version,
|
||||
String updatedVersion,
|
||||
String groupId,
|
||||
String artifactId,
|
||||
Settings settings )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
try
|
||||
|
@ -440,7 +458,9 @@ public class DefaultPluginVersionManager
|
|||
}
|
||||
}
|
||||
|
||||
private void addNewVersionToRejectedListInExisting( String groupId, String artifactId, String rejectedVersion )
|
||||
private void addNewVersionToRejectedListInExisting( String groupId,
|
||||
String artifactId,
|
||||
String rejectedVersion )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId );
|
||||
|
@ -465,7 +485,8 @@ public class DefaultPluginVersionManager
|
|||
}
|
||||
}
|
||||
|
||||
private String resolveExistingFromPluginRegistry( String groupId, String artifactId )
|
||||
private String resolveExistingFromPluginRegistry( String groupId,
|
||||
String artifactId )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId );
|
||||
|
@ -482,7 +503,8 @@ public class DefaultPluginVersionManager
|
|||
return version;
|
||||
}
|
||||
|
||||
private org.apache.maven.plugin.registry.Plugin getPlugin( String groupId, String artifactId,
|
||||
private org.apache.maven.plugin.registry.Plugin getPlugin( String groupId,
|
||||
String artifactId,
|
||||
PluginRegistry pluginRegistry )
|
||||
{
|
||||
Map pluginsByKey;
|
||||
|
@ -501,12 +523,15 @@ public class DefaultPluginVersionManager
|
|||
return (org.apache.maven.plugin.registry.Plugin) pluginsByKey.get( pluginKey );
|
||||
}
|
||||
|
||||
private String constructPluginKey( String groupId, String artifactId )
|
||||
private String constructPluginKey( String groupId,
|
||||
String artifactId )
|
||||
{
|
||||
return groupId + ":" + artifactId;
|
||||
}
|
||||
|
||||
private String getVersionFromPluginConfig( String groupId, String artifactId, MavenProject project,
|
||||
private String getVersionFromPluginConfig( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
boolean resolveAsReportPlugin )
|
||||
{
|
||||
String version = null;
|
||||
|
@ -545,7 +570,9 @@ public class DefaultPluginVersionManager
|
|||
return version;
|
||||
}
|
||||
|
||||
private void updatePluginVersionInRegistry( String groupId, String artifactId, String version )
|
||||
private void updatePluginVersionInRegistry( String groupId,
|
||||
String artifactId,
|
||||
String version )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId );
|
||||
|
@ -587,7 +614,9 @@ public class DefaultPluginVersionManager
|
|||
writeUserRegistry( groupId, artifactId, pluginRegistry );
|
||||
}
|
||||
|
||||
private void writeUserRegistry( String groupId, String artifactId, PluginRegistry pluginRegistry )
|
||||
private void writeUserRegistry( String groupId,
|
||||
String artifactId,
|
||||
PluginRegistry pluginRegistry )
|
||||
{
|
||||
File pluginRegistryFile = pluginRegistry.getRuntimeInfo().getFile();
|
||||
|
||||
|
@ -620,7 +649,8 @@ public class DefaultPluginVersionManager
|
|||
}
|
||||
}
|
||||
|
||||
private PluginRegistry getPluginRegistry( String groupId, String artifactId )
|
||||
private PluginRegistry getPluginRegistry( String groupId,
|
||||
String artifactId )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
if ( pluginRegistry == null )
|
||||
|
@ -649,8 +679,11 @@ public class DefaultPluginVersionManager
|
|||
return pluginRegistry;
|
||||
}
|
||||
|
||||
private String resolveMetaVersion( String groupId, String artifactId, MavenProject project,
|
||||
ArtifactRepository localRepository, String metaVersionId )
|
||||
private String resolveMetaVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
ArtifactRepository localRepository,
|
||||
String metaVersionId )
|
||||
throws PluginVersionResolutionException, InvalidPluginException
|
||||
{
|
||||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||
|
|
|
@ -20,17 +20,16 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.plugin.InvalidPluginException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
|
||||
public interface PluginVersionManager
|
||||
{
|
||||
String ROLE = PluginVersionManager.class.getName();
|
||||
|
||||
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||
|
||||
String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,14 @@
|
|||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
|
Loading…
Reference in New Issue