Author: jdcasey
Date: Mon Jun 6 17:37:01 2005
New Revision: 187639
URL: http://svn.apache.org/viewcvs?rev=187639&view=rev
Log:
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
Modified:
maven/components/trunk/maven-core/pom.xml
maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
maven/components/trunk/maven-plugins/maven-deploy-plugin/pom.xml
maven/components/trunk/maven-plugins/pom.xml
Modified: maven/components/trunk/maven-core/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/pom.xml?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
--- maven/components/trunk/maven-core/pom.xml (original)
+++ maven/components/trunk/maven-core/pom.xml Mon Jun 6 17:37:01 2005
@@ -15,11 +15,6 @@
<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>
<version>2.0-SNAPSHOT</version>
@@ -77,12 +72,6 @@
<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>
<version>1.0-alpha-4-SNAPSHOT</version>
@@ -95,6 +84,12 @@
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</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>
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
Mon Jun 6 17:37:01 2005
@@ -44,7 +44,7 @@
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 @@
// bring the maven component to life for use.
//
----------------------------------------------------------------------
- ArtifactEnabledEmbedder embedder = new ArtifactEnabledEmbedder();
+ Embedder embedder = new Embedder();
try
{
@@ -276,7 +276,7 @@
}
}
- 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 @@
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 @@
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
{
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Mon Jun 6 17:37:01 2005
@@ -38,10 +38,9 @@
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.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 @@
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 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 @@
}
// 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 @@
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 @@
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 void executeMojo( MavenSession session, MojoDescriptor
mojoDescriptor )
throws ArtifactResolutionException, PluginManagerException,
MojoExecutionException
{
+ PlexusContainer pluginContainer = null;
+
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
{
@@ -357,7 +374,16 @@
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 @@
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 @@
}
finally
{
- releaseComponent( plugin );
+ try
+ {
+ pluginContainer.release( plugin );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ if( getLogger().isErrorEnabled() )
+ {
+ getLogger().error( "Error releasing plugin - ignoring.", e
);
+ }
+ }
}
}
@@ -527,7 +563,7 @@
// ----------------------------------------------------------------------
private void populatePluginFields( Mojo plugin, MojoDescriptor
mojoDescriptor, PlexusConfiguration configuration,
- ExpressionEvaluator expressionEvaluator
)
+ PlexusContainer pluginContainer,
ExpressionEvaluator expressionEvaluator )
throws PluginConfigurationException
{
ComponentConfigurator configurator = null;
@@ -539,14 +575,14 @@
// 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 @@
{
try
{
- container.release( configurator );
+ pluginContainer.release( configurator );
}
catch ( ComponentLifecycleException e )
{
@@ -599,7 +635,7 @@
*/
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 @@
"bsh",
"classworlds",
"doxia-core",
- "marmalade-core",
"maven-artifact",
"maven-core",
"maven-model",
@@ -806,12 +841,9 @@
"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"
} );
Modified:
maven/components/trunk/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java
(original)
+++
maven/components/trunk/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java
Mon Jun 6 17:37:01 2005
@@ -18,7 +18,7 @@
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 static PlexusContainer getContainerInstance()
{
- return new DefaultArtifactEnabledContainer();
+ return new DefaultPlexusContainer();
}
public static void customizeContext( PlexusContainer container, File
basedir, File mavenHome, File mavenHomeLocal )
Modified:
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
---
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
(original)
+++
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
Mon Jun 6 17:37:01 2005
@@ -100,7 +100,12 @@
{
return groupId + ":" + artifactId + ":" + version;
}
-
+
+ public String getPluginLookupKey()
+ {
+ return groupId + ":" + artifactId;
+ }
+
public String getId()
{
String id = constructPluginKey( groupId, artifactId, version );
Modified: maven/components/trunk/maven-plugins/maven-deploy-plugin/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-deploy-plugin/pom.xml?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-deploy-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-deploy-plugin/pom.xml Mon Jun 6
17:37:01 2005
@@ -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>
Modified: maven/components/trunk/maven-plugins/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/pom.xml?rev=187639&r1=187638&r2=187639&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/pom.xml (original)
+++ maven/components/trunk/maven-plugins/pom.xml Mon Jun 6 17:37:01 2005
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]