From 11a113d316ae75c3ed613fc7d75bc69d27ee7790 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Thu, 3 May 2007 19:50:08 +0000 Subject: [PATCH] o we simply can't survive right now without inserting plexus utils, we just have too many builds without declared dependencies on it o cleaning up some unused stuff from the bootstrap git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@534974 13f79535-47bb-0310-9956-ffa450edef68 --- build.properties | 3 -- build.xml | 6 --- .../extension/DefaultExtensionManager.java | 4 +- .../maven/plugin/DefaultPluginManager.java | 52 +++++++++++++++++++ ...luginParameterExpressionEvaluatorTest.java | 1 + 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/build.properties b/build.properties index 7a7e24cd72..566badbec4 100644 --- a/build.properties +++ b/build.properties @@ -19,11 +19,8 @@ classworlds.version=1.2-alpha-7 plexus-active-collections.version=1.0-beta-1 plexus.version=1.0-alpha-24 plexus-utils.version=1.4.1 -plexus-interactivity-api.version=1.0-alpha-6-SNAPSHOT commons-cli.version=1.0 -commons-lang.version=2.1 wagon.version=1.0-beta-2 -jsch.version=0.1.27 doxia.version=1.0-alpha-9-SNAPSHOT modello.version=1.0-alpha-13 junit.version=3.8.1 diff --git a/build.xml b/build.xml index ca2ef84113..72d57e5ee8 100644 --- a/build.xml +++ b/build.xml @@ -121,7 +121,6 @@ under the License. - @@ -131,11 +130,6 @@ under the License. - - - - - diff --git a/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java b/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java index a45e3d01a1..e20575e5e8 100644 --- a/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java +++ b/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java @@ -20,11 +20,10 @@ */ import org.apache.maven.ArtifactFilterManager; -import org.apache.maven.wagon.Wagon; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; @@ -39,7 +38,6 @@ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; 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 ff88737de0..df4edcf380 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 @@ -455,6 +455,8 @@ private Set getPluginArtifacts( Artifact pluginArtifact, Plugin plugin, MavenPro pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); } + checkPlexusUtils( resolutionGroup, artifactFactory ); + Set dependencies = new HashSet( resolutionGroup.getArtifacts() ); List repositories = new ArrayList(); @@ -1316,4 +1318,54 @@ public Map getPluginComponents( Plugin plugin, String role ) return container.lookupMap( role, pluginRealm ); } + + public static void checkPlexusUtils( ResolutionGroup resolutionGroup, ArtifactFactory artifactFactory ) + { + // ---------------------------------------------------------------------------- + // If the plugin already declares a dependency on plexus-utils then we're all + // set as the plugin author is aware of its use. If we don't have a dependency + // on plexus-utils then we must protect users from stupid plugin authors who + // did not declare a direct dependency on plexus-utils because the version + // Maven uses is hidden from downstream use. We will also bump up any + // anything below 1.1 to 1.1 as this mimics the behaviour in 2.0.5 where + // plexus-utils 1.1 was being forced into use. + // ---------------------------------------------------------------------------- + + VersionRange vr = null; + + try + { + vr = VersionRange.createFromVersionSpec( "[1.1,)" ); + } + catch ( InvalidVersionSpecificationException e ) + { + // Won't happen + } + + boolean plexusUtilsPresent = false; + + for ( Iterator i = resolutionGroup.getArtifacts().iterator(); i.hasNext(); ) + { + Artifact a = (Artifact) i.next(); + + if ( a.getArtifactId().equals( "plexus-utils" ) && + vr.containsVersion( new DefaultArtifactVersion( a.getVersion() ) ) ) + { + plexusUtilsPresent = true; + + break; + } + } + + if ( !plexusUtilsPresent ) + { + // We will add plexus-utils as every plugin was getting this anyway from Maven itself. We will set the + // version to the latest version we know that works as of the 2.0.6 release. We set the scope to runtime + // as this is what's implicitly happening in 2.0.6. + + resolutionGroup.getArtifacts().add( artifactFactory.createArtifact( "org.codehaus.plexus", + "plexus-utils", "1.1", + Artifact.SCOPE_RUNTIME, "jar" ) ); + } + } } diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index 3ca7cdca13..284d395e42 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -48,6 +48,7 @@ import java.util.List; import java.util.Properties; + /** * @author Jason van Zyl * @version $Id: PluginParameterExpressionEvaluatorTest.java,v 1.5 2005/03/08