From 9131de703971744f9dab58734e4b57f3f2d66dd8 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 11 Aug 2009 19:51:12 +0000 Subject: [PATCH] o Fixed missing version resolution for extension plugins git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803266 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/lifecycle/DefaultLifecycleExecutor.java | 2 +- .../apache/maven/lifecycle/LifecycleExecutor.java | 5 +++-- .../maven/project/DefaultModelBuildingListener.java | 4 ++-- .../maven/project/DefaultProjectBuildingHelper.java | 12 +++++++++++- .../apache/maven/project/ProjectBuildingHelper.java | 3 ++- .../apache/maven/project/EmptyLifecycleExecutor.java | 6 ++++++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index ed3c5bd77a..3440129e4b 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -925,7 +925,7 @@ public class DefaultLifecycleExecutor return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest ); } - private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest ) + public void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest ) throws PluginNotFoundException { ArtifactRepository localRepository = repositoryRequest.getLocalRepository(); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java index 0c83eccf1b..592e2e232d 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java @@ -20,10 +20,8 @@ package org.apache.maven.lifecycle; */ import java.util.Collection; -import java.util.List; import java.util.Set; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; @@ -75,6 +73,9 @@ public interface LifecycleExecutor // void populateDefaultConfigurationForPlugins( Collection plugins, RepositoryRequest repositoryRequest ) throws LifecycleExecutionException; + + void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest ) + throws PluginNotFoundException; void execute( MavenSession session ); } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java index 106b7b2002..7a46c7ff97 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.model.Model; import org.apache.maven.model.building.AbstractModelBuildingListener; import org.apache.maven.model.building.ModelBuildingEvent; @@ -142,7 +142,7 @@ class DefaultModelBuildingListener projectRealm = projectBuildingHelper.createProjectRealm( model, repositoryRequest ); } - catch ( ArtifactResolutionException e ) + catch ( AbstractArtifactResolutionException e ) { event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(), e ); } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index 4a4aa9dfad..f5154ed52f 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -36,12 +36,14 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.classrealm.ClassRealmManager; +import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; +import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; @@ -79,6 +81,9 @@ public class DefaultProjectBuildingHelper @Requirement private ArtifactFilterManager artifactFilterManager; + @Requirement + private LifecycleExecutor lifecycleExecutor; + public List createArtifactRepositories( List pomRepositories, List externalRepositories ) throws InvalidRepositoryException @@ -103,7 +108,7 @@ public class DefaultProjectBuildingHelper } public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException + throws ArtifactResolutionException, PluginNotFoundException { ClassRealm projectRealm = null; @@ -142,6 +147,11 @@ public class DefaultProjectBuildingHelper for ( Plugin plugin : extensionPlugins ) { + if ( plugin.getVersion() == null ) + { + lifecycleExecutor.resolvePluginVersion( plugin, repositoryRequest ); + } + Artifact artifact = repositorySystem.createPluginArtifact( plugin ); Set dependencies = new LinkedHashSet(); diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java index dfb82b2126..3a6828c083 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java @@ -27,6 +27,7 @@ import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.model.Model; import org.apache.maven.model.Repository; +import org.apache.maven.plugin.PluginNotFoundException; import org.codehaus.plexus.classworlds.realm.ClassRealm; /** @@ -61,6 +62,6 @@ public interface ProjectBuildingHelper * @throws ArtifactResolutionException If any build extension could not be resolved. */ ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException; + throws ArtifactResolutionException, PluginNotFoundException; } diff --git a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java index e8e655db9a..6dbca59ce7 100644 --- a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java +++ b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java @@ -80,4 +80,10 @@ public class EmptyLifecycleExecutor throws LifecycleExecutionException { } + + public void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest ) + throws PluginNotFoundException + { + } + }