From db225079d5ba1679d429da32e949c6e3bacbafab Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Sat, 20 Jan 2007 02:45:20 +0000 Subject: [PATCH] Fixing plugin-discovery when one plugin depends on another, and the pluginCollector sees a plugin before that plugin is meant to be added with its componentRealm. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@498048 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/DefaultPluginManager.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 46d5151a1e..6c3b1f452f 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -201,6 +201,7 @@ public class DefaultPluginManager throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException { + getLogger().debug( "In verifyVersionedPlugin for: " + plugin.getKey() ); // TODO: this might result in an artifact "RELEASE" being resolved continuously // FIXME: need to find out how a plugin gets marked as 'installed' @@ -225,10 +226,10 @@ public class DefaultPluginManager artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository ); - if ( !pluginCollector.isPluginInstalled( plugin ) ) - { - addPlugin( plugin, pluginArtifact, project, localRepository ); - } +// if ( !pluginCollector.isPluginInstalled( plugin ) ) +// { +// } + addPlugin( plugin, pluginArtifact, project, localRepository ); project.addPlugin( plugin ); } @@ -345,6 +346,16 @@ public class DefaultPluginManager private void addPlugin( Plugin plugin, Plugin projectPlugin, Artifact pluginArtifact, Set artifacts ) throws ArtifactNotFoundException, ArtifactResolutionException, PluginManagerException, InvalidPluginException { + // TODO When/if we go to project-level plugin instances (like for plugin-level deps in the + // POM), we need to undo this somehow. + ClassRealm pluginRealm = container.getComponentRealm( projectPlugin.getKey() ); + + if ( pluginRealm != null && pluginRealm != container.getContainerRealm() ) + { + getLogger().debug( "Realm already exists for: " + projectPlugin.getKey() + ". Skipping addition..." ); + // we've already discovered this plugin, and configured it, so skip it this time. + return; + } // ---------------------------------------------------------------------------- // Realm creation for a plugin @@ -1253,6 +1264,8 @@ public class DefaultPluginManager public Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException { + getLogger().debug( "Looking for plugin realm: " + plugin + " using: " + pluginCollector ); + ClassRealm pluginRealm = pluginCollector.getPluginDescriptor( plugin ).getClassRealm(); if ( pluginRealm == null )