mirror of https://github.com/apache/maven.git
o Removed dependency on plexus-container-artifact, using nested DefaultPlexusContainer instances instead for plugin isolation.
o Moved marmalade support dependencies out of maven-core, since they can be supported on demand now o changed the ordering of the ant and assembly plugins, to show that the classloader (plugin param) bug is fixed. o added a method in PluginDescriptor which is similar to o.a.m.model.Plugin.getId() (I think that's the method; it's the one that results in a key of 'g:a') o moved wagon-ssh dependency into maven-core, since there is a new issue related to nested containers and wagons which are introduced as plugin dependencies. This should be solved using a mechanism similar to plugin-manager for wagon-manager impl in future anyway git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@187639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
81aa1b6b90
commit
a96a03d0a0
|
@ -14,11 +14,6 @@
|
|||
<artifactId>wagon-provider-api</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-container-artifact</artifactId>
|
||||
<version>1.0-alpha-4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-monitor</artifactId>
|
||||
|
@ -76,12 +71,6 @@
|
|||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-script-marmalade</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
|
@ -98,6 +87,12 @@
|
|||
<version>1.0-alpha-3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reports>
|
||||
<plugins>
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.codehaus.classworlds.ClassWorld;
|
|||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
|
||||
import org.codehaus.plexus.embed.Embedder;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.LoggerManager;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
@ -148,7 +148,7 @@ public class MavenCli
|
|||
// bring the maven component to life for use.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ArtifactEnabledEmbedder embedder = new ArtifactEnabledEmbedder();
|
||||
Embedder embedder = new Embedder();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
private static MavenExecutionRequest createRequest( List files, ArtifactEnabledEmbedder embedder,
|
||||
private static MavenExecutionRequest createRequest( List files, Embedder embedder,
|
||||
CommandLine commandLine, Settings settings,
|
||||
EventDispatcher eventDispatcher, LoggerManager manager )
|
||||
throws ComponentLookupException
|
||||
|
@ -330,7 +330,7 @@ public class MavenCli
|
|||
return files;
|
||||
}
|
||||
|
||||
private static Maven createMavenInstance( ArtifactEnabledEmbedder embedder )
|
||||
private static Maven createMavenInstance( Embedder embedder )
|
||||
throws ComponentLookupException
|
||||
{
|
||||
// TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place (likewise logger).
|
||||
|
@ -340,7 +340,7 @@ public class MavenCli
|
|||
return (Maven) embedder.lookup( Maven.ROLE );
|
||||
}
|
||||
|
||||
private static ArtifactRepository createLocalRepository( ArtifactEnabledEmbedder embedder, Settings settings,
|
||||
private static ArtifactRepository createLocalRepository( Embedder embedder, Settings settings,
|
||||
CommandLine commandLine )
|
||||
throws ComponentLookupException
|
||||
{
|
||||
|
|
|
@ -38,10 +38,9 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.ArtifactEnabledContainer;
|
||||
import org.codehaus.plexus.ArtifactEnabledContainerException;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
||||
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
|
||||
|
@ -62,8 +61,10 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
|||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -159,22 +160,21 @@ public class DefaultPluginManager
|
|||
return (PluginDescriptor) pluginDescriptorsByPrefix.get( prefix );
|
||||
}
|
||||
|
||||
private boolean isPluginInstalled( String groupId, String artifactId, String version )
|
||||
private boolean isPluginInstalled( String pluginKey )
|
||||
{
|
||||
// String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
|
||||
// TODO: see comment in getPluginDescriptor
|
||||
String key = groupId + ":" + artifactId;
|
||||
return pluginDescriptors.containsKey( key );
|
||||
return pluginDescriptors.containsKey( pluginKey );
|
||||
}
|
||||
|
||||
private boolean isPluginInstalled( String prefix )
|
||||
private boolean isPluginInstalledForPrefix( String prefix )
|
||||
{
|
||||
return pluginDescriptorsByPrefix.containsKey( prefix );
|
||||
}
|
||||
|
||||
public PluginDescriptor verifyPlugin( String prefix )
|
||||
{
|
||||
if ( !isPluginInstalled( prefix ) )
|
||||
if ( !isPluginInstalledForPrefix( prefix ) )
|
||||
{
|
||||
// TODO: lookup remotely
|
||||
}
|
||||
|
@ -184,6 +184,9 @@ public class DefaultPluginManager
|
|||
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenSession session )
|
||||
throws ArtifactResolutionException, PluginManagerException
|
||||
{
|
||||
|
||||
String pluginKey = groupId + ":" + artifactId;
|
||||
|
||||
// TODO: this should be possibly outside
|
||||
if ( version == null )
|
||||
{
|
||||
|
@ -232,17 +235,18 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
||||
if ( !isPluginInstalled( groupId, artifactId, version ) )
|
||||
if ( !isPluginInstalled( pluginKey ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
Artifact pluginArtifact = artifactFactory.createArtifact( groupId, artifactId, version, null,
|
||||
Artifact pluginArtifact = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
|
||||
MojoDescriptor.MAVEN_PLUGIN, null );
|
||||
addPlugin( pluginArtifact, session );
|
||||
|
||||
addPlugin( pluginKey, pluginArtifact, session );
|
||||
|
||||
version = pluginArtifact.getBaseVersion();
|
||||
}
|
||||
catch ( ArtifactEnabledContainerException e )
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new PluginManagerException( "Error occurred in the artifact container attempting to download plugin " +
|
||||
groupId + ":" + artifactId, e );
|
||||
|
@ -268,8 +272,8 @@ public class DefaultPluginManager
|
|||
return getPluginDescriptor( groupId, artifactId, version );
|
||||
}
|
||||
|
||||
protected void addPlugin( Artifact pluginArtifact, MavenSession session )
|
||||
throws ArtifactEnabledContainerException, ArtifactResolutionException, ComponentLookupException
|
||||
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenSession session )
|
||||
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
|
||||
{
|
||||
ArtifactResolver artifactResolver = null;
|
||||
MavenProjectBuilder mavenProjectBuilder = null;
|
||||
|
@ -282,10 +286,21 @@ public class DefaultPluginManager
|
|||
|
||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
|
||||
( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact, artifactResolver,
|
||||
session.getPluginRepositories(),
|
||||
session.getLocalRepository(), metadataSource,
|
||||
artifactFilter );
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( pluginArtifact ), session.getRemoteRepositories(), session.getLocalRepository(), metadataSource, artifactFilter );
|
||||
|
||||
Map resolved = result.getArtifacts();
|
||||
|
||||
List files = new ArrayList();
|
||||
|
||||
for ( Iterator it = resolved.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
File artifactFile = artifact.getFile();
|
||||
|
||||
files.add( artifact.getFile() );
|
||||
}
|
||||
|
||||
container.createChildContainer( pluginKey, files, Collections.EMPTY_MAP, Collections.singletonList( this ) );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -319,6 +334,8 @@ public class DefaultPluginManager
|
|||
public void executeMojo( MavenSession session, MojoDescriptor mojoDescriptor )
|
||||
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
|
||||
{
|
||||
PlexusContainer pluginContainer = null;
|
||||
|
||||
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||
{
|
||||
|
||||
|
@ -357,7 +374,16 @@ public class DefaultPluginManager
|
|||
|
||||
try
|
||||
{
|
||||
plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
||||
String pluginKey = mojoDescriptor.getPluginDescriptor().getPluginLookupKey();
|
||||
|
||||
pluginContainer = container.getChildContainer( pluginKey );
|
||||
|
||||
if( pluginContainer == null )
|
||||
{
|
||||
throw new PluginConfigurationException( "Cannot find PlexusContainer for plugin: " + pluginKey );
|
||||
}
|
||||
|
||||
plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
||||
plugin.setLog( mojoLogger );
|
||||
|
||||
String goalId = mojoDescriptor.getGoal();
|
||||
|
@ -395,9 +421,9 @@ public class DefaultPluginManager
|
|||
try
|
||||
{
|
||||
getPluginConfigurationFromExpressions( plugin, mojoDescriptor, mergedConfiguration,
|
||||
expressionEvaluator );
|
||||
pluginContainer, expressionEvaluator );
|
||||
|
||||
populatePluginFields( plugin, mojoDescriptor, mergedConfiguration, expressionEvaluator );
|
||||
populatePluginFields( plugin, mojoDescriptor, mergedConfiguration, pluginContainer, expressionEvaluator );
|
||||
}
|
||||
catch ( ExpressionEvaluationException e )
|
||||
{
|
||||
|
@ -435,7 +461,17 @@ public class DefaultPluginManager
|
|||
}
|
||||
finally
|
||||
{
|
||||
releaseComponent( plugin );
|
||||
try
|
||||
{
|
||||
pluginContainer.release( plugin );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
if( getLogger().isErrorEnabled() )
|
||||
{
|
||||
getLogger().error( "Error releasing plugin - ignoring.", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,7 +563,7 @@ public class DefaultPluginManager
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
|
||||
ExpressionEvaluator expressionEvaluator )
|
||||
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
||||
throws PluginConfigurationException
|
||||
{
|
||||
ComponentConfigurator configurator = null;
|
||||
|
@ -539,14 +575,14 @@ public class DefaultPluginManager
|
|||
// TODO: should this be known to the component factory instead? And if so, should configuration be part of lookup?
|
||||
if ( StringUtils.isNotEmpty( configuratorId ) )
|
||||
{
|
||||
configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, configuratorId );
|
||||
configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId );
|
||||
}
|
||||
else
|
||||
{
|
||||
configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
|
||||
configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE );
|
||||
}
|
||||
|
||||
configurator.configureComponent( plugin, configuration, expressionEvaluator );
|
||||
configurator.configureComponent( plugin, configuration, expressionEvaluator, pluginContainer.getContainerRealm() );
|
||||
|
||||
}
|
||||
catch ( ComponentConfigurationException e )
|
||||
|
@ -564,7 +600,7 @@ public class DefaultPluginManager
|
|||
{
|
||||
try
|
||||
{
|
||||
container.release( configurator );
|
||||
pluginContainer.release( configurator );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
|
@ -599,7 +635,7 @@ public class DefaultPluginManager
|
|||
*/
|
||||
private void getPluginConfigurationFromExpressions( Mojo plugin, MojoDescriptor goal,
|
||||
PlexusConfiguration mergedConfiguration,
|
||||
ExpressionEvaluator expressionEvaluator )
|
||||
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
||||
throws ExpressionEvaluationException, PluginConfigurationException
|
||||
{
|
||||
List parameters = goal.getParameters();
|
||||
|
@ -795,7 +831,6 @@ public class DefaultPluginManager
|
|||
"bsh",
|
||||
"classworlds",
|
||||
"doxia-core",
|
||||
"marmalade-core",
|
||||
"maven-artifact",
|
||||
"maven-core",
|
||||
"maven-model",
|
||||
|
@ -806,12 +841,9 @@ public class DefaultPluginManager
|
|||
"maven-project",
|
||||
"maven-reporting-api",
|
||||
"maven-script-beanshell",
|
||||
"maven-script-marmalade",
|
||||
"maven-settings",
|
||||
"plexus-bsh-factory",
|
||||
"plexus-container-artifact",
|
||||
"plexus-container-default",
|
||||
"plexus-marmalade-factory",
|
||||
"plexus-utils",
|
||||
"wagon-provider-api"
|
||||
} );
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.maven;
|
|||
|
||||
import org.codehaus.classworlds.ClassRealm;
|
||||
import org.codehaus.classworlds.ClassWorld;
|
||||
import org.codehaus.plexus.DefaultArtifactEnabledContainer;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -37,7 +37,7 @@ public class MavenTestUtils
|
|||
|
||||
public static PlexusContainer getContainerInstance()
|
||||
{
|
||||
return new DefaultArtifactEnabledContainer();
|
||||
return new DefaultPlexusContainer();
|
||||
}
|
||||
|
||||
public static void customizeContext( PlexusContainer container, File basedir, File mavenHome, File mavenHomeLocal )
|
||||
|
|
|
@ -100,7 +100,12 @@ public class PluginDescriptor
|
|||
{
|
||||
return groupId + ":" + artifactId + ":" + version;
|
||||
}
|
||||
|
||||
|
||||
public String getPluginLookupKey()
|
||||
{
|
||||
return groupId + ":" + artifactId;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
String id = constructPluginKey( groupId, artifactId, version );
|
||||
|
|
|
@ -21,17 +21,5 @@
|
|||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-alpha-2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
||||
|
|
|
@ -76,9 +76,8 @@
|
|||
</site>
|
||||
</distributionManagement>
|
||||
<modules>
|
||||
<!-- Due to CL bug, assembly must be first -->
|
||||
<module>maven-assembly-plugin</module>
|
||||
<module>maven-ant-plugin</module>
|
||||
<module>maven-assembly-plugin</module>
|
||||
<module>maven-clean-plugin</module>
|
||||
<module>maven-compiler-plugin</module>
|
||||
<module>maven-deploy-plugin</module>
|
||||
|
|
Loading…
Reference in New Issue