You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2008/03/14 01:47:41 UTC
svn commit: r636942 - in
/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin:
DefaultPluginManager.java MavenPluginCollector.java
identifier/PluginCoordinate.java identifier/PluginIdentifier.java
Author: brianf
Date: Thu Mar 13 17:47:38 2008
New Revision: 636942
URL: http://svn.apache.org/viewvc?rev=636942&view=rev
Log:
MNG-3284: rolling back the patch, it breaks lots of stuff.
Removed:
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/identifier/PluginCoordinate.java
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/identifier/PluginIdentifier.java
Modified:
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=636942&r1=636941&r2=636942&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Thu Mar 13 17:47:38 2008
@@ -48,7 +48,6 @@
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
-import org.apache.maven.plugin.identifier.PluginCoordinate;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.version.PluginVersionManager;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
@@ -204,9 +203,7 @@
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
- PluginCoordinate pc = new PluginCoordinate( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() );
-
- PlexusContainer pluginContainer = container.getChildContainer( pc.toString() );
+ PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() );
File pluginFile = pluginArtifact.getFile();
@@ -296,9 +293,7 @@
try
{
- PluginCoordinate pc = new PluginCoordinate(plugin);
-
- child = container.createChildContainer( pc.toString(),
+ child = container.createChildContainer( plugin.getKey(),
Collections.singletonList( pluginArtifact.getFile() ),
Collections.EMPTY_MAP,
Collections.singletonList( pluginCollector ) );
@@ -451,7 +446,7 @@
try
{
Thread.currentThread().setContextClassLoader(
- mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() );
+ mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() );
plugin.execute();
@@ -585,9 +580,7 @@
{
String pluginKey = pluginDescriptor.getPluginLookupKey();
- PluginCoordinate pc = new PluginCoordinate(pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion());
-
- PlexusContainer pluginContainer = container.getChildContainer( pc.toString() );
+ PlexusContainer pluginContainer = container.getChildContainer( pluginKey );
if ( pluginContainer == null )
{
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java?rev=636942&r1=636941&r2=636942&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java Thu Mar 13 17:47:38 2008
@@ -21,81 +21,47 @@
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.identifier.PluginCoordinate;
-import org.apache.maven.plugin.identifier.PluginIdentifier;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import org.codehaus.plexus.logging.AbstractLogEnabled;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-/**
- * This class contains references to the plugins that have been loaded,
- * indexed in a way so that they can be looked up.
- *
- * It listens for new plugins being loaded, and adds them into the index
- * as this happens.
- *
- */
public class MavenPluginCollector
extends AbstractLogEnabled
implements ComponentDiscoveryListener
{
- /**
- * A 1st-past-the post list of prefixes to descriptors
- * Map {prefix:String -> PluginDescriptor}
- */
- private Map pluginIdsByPrefix = new HashMap();
- /**
- * Map {PluginCoordinate -> PluginDescriptor}}
- */
+ private Set pluginsInProcess = new HashSet();
+
private Map pluginDescriptors = new HashMap();
- /**
- * Keep track of the order that particular plugins have been
- * seen, in case a move to a non 1st past the post for
- * descriptors.
- *
- * Map {PluginIdentifier -> List {PluginDescriptor}}
- */
- private Map pluginDeclarations = new HashMap();
-
+ private Map pluginIdsByPrefix = new HashMap();
+
// ----------------------------------------------------------------------
// Mojo discovery
// ----------------------------------------------------------------------
public void componentDiscovered( ComponentDiscoveryEvent event )
- {
+ {
ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor();
-
+
if ( componentSetDescriptor instanceof PluginDescriptor )
{
PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor;
// TODO: see comment in getPluginDescriptor
-
- PluginCoordinate coordinate = new PluginCoordinate( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion() );
- PluginIdentifier identifier = coordinate.getIdentifier();
+ String key = Plugin.constructKey( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId() );
- // Don't overwrite any existing found descriptor, as things
- // like the ClassRealm that has been constructed will disappear,
- // causing reactor builds to fail.
- if( !pluginDescriptors.containsKey(coordinate))
- {
- pluginDescriptors.put( coordinate, pluginDescriptor );
- }
-
- // Store that we've seen the plugin by prefix, for the 1st past the post
- if( !pluginDeclarations.containsKey(identifier) )
+ if ( !pluginsInProcess.contains( key ) )
{
- pluginDeclarations.put(identifier, new ArrayList());
+ pluginsInProcess.add( key );
+
+ pluginDescriptors.put( key, pluginDescriptor );
// TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere
// we also need to deal with multiple versions somehow - currently, first wins
@@ -104,7 +70,6 @@
pluginIdsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor );
}
}
- ((List)pluginDeclarations.get(identifier)).add(pluginDescriptor);
}
}
@@ -113,34 +78,15 @@
// TODO: include version, but can't do this in the plugin manager as it is not resolved to the right version
// at that point. Instead, move the duplication check to the artifact container, or store it locally based on
// the unresolved version?
-
- // Has the plugin got a version specified (think that it ought to)
- PluginCoordinate coordinate = new PluginCoordinate(plugin);
- PluginIdentifier pluginIdentifier = coordinate.getIdentifier();
-
- if( plugin.getVersion() != null )
- {
- PluginDescriptor pluginDescriptor = (PluginDescriptor)pluginDescriptors.get(coordinate);
- if( pluginDescriptor != null )
- {
- return pluginDescriptor;
- }
- }
-
- getLogger().error("No version for " + pluginIdentifier);
-
- return null;
+ return (PluginDescriptor) pluginDescriptors.get( plugin.getKey() );
}
public boolean isPluginInstalled( Plugin plugin )
- {
+ {
// TODO: see comment in getPluginDescriptor
-
- PluginCoordinate coordinate = new PluginCoordinate(plugin);
-
- return pluginDescriptors.containsKey(coordinate);
+ return pluginDescriptors.containsKey( plugin.getKey() );
}
-
+
public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
{
return (PluginDescriptor) pluginIdsByPrefix.get( prefix );
@@ -148,11 +94,8 @@
public void flushPluginDescriptor( Plugin plugin )
{
- PluginCoordinate coordinate = new PluginCoordinate(plugin);
- PluginIdentifier identifier = coordinate.getIdentifier();
-
- pluginDeclarations.remove( identifier );
- pluginDescriptors.remove ( coordinate );
+ pluginsInProcess.remove( plugin.getKey() );
+ pluginDescriptors.remove( plugin.getKey() );
for ( Iterator it = pluginIdsByPrefix.entrySet().iterator(); it.hasNext(); )
{