From 6e6f881bc8dfde409613f22af3ce9d848f163001 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 20 Oct 2009 09:50:35 +0000 Subject: [PATCH] o Specialized exception git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@827020 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/DefaultModelBuildingListener.java | 4 ++-- .../project/DefaultProjectBuildingHelper.java | 14 +++++++++++--- .../maven/project/ProjectBuildingHelper.java | 6 +++--- .../maven/project/EmptyProjectBuildingHelper.java | 4 ---- 4 files changed, 16 insertions(+), 12 deletions(-) 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 f12a676dc3..6fadb20bf2 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,10 +24,10 @@ 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.model.Model; import org.apache.maven.model.building.AbstractModelBuildingListener; import org.apache.maven.model.building.ModelBuildingEvent; +import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; /** @@ -116,7 +116,7 @@ class DefaultModelBuildingListener project.setClassRealm( record.realm ); project.setExtensionArtifactFilter( record.extensionArtifactFilter ); } - catch ( ArtifactResolutionException e ) + catch ( PluginResolutionException 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 c5eb920a45..78f3f4e27c 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 @@ -50,6 +50,7 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.plugin.ExtensionRealmCache; import org.apache.maven.plugin.PluginArtifactsCache; +import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.DefaultPluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; @@ -135,7 +136,7 @@ public class DefaultProjectBuildingHelper public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException, PluginVersionResolutionException + throws PluginResolutionException, PluginVersionResolutionException { ClassRealm projectRealm = null; @@ -381,7 +382,7 @@ public class DefaultProjectBuildingHelper } private List resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException + throws PluginResolutionException { Artifact extensionArtifact = repositorySystem.createPluginArtifact( extensionPlugin ); @@ -405,7 +406,14 @@ public class DefaultProjectBuildingHelper ArtifactResolutionResult result = repositorySystem.resolve( request ); - resolutionErrorHandler.throwErrors( request, result ); + try + { + resolutionErrorHandler.throwErrors( request, result ); + } + catch ( ArtifactResolutionException e ) + { + throw new PluginResolutionException( extensionPlugin, e ); + } List extensionArtifacts = new ArrayList( result.getArtifacts() ); 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 b156c34a2c..390af575e6 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 @@ -24,9 +24,9 @@ import java.util.List; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; 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.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; /** @@ -62,10 +62,10 @@ public interface ProjectBuildingHelper * @param model The model to create the project realm for, must not be {@code null} * @param repositoryRequest The repository request to use for artifact resolution, must not be {@code null}. * @return The record with the project realm and extension artifact filter, never {@code null}. - * @throws ArtifactResolutionException If any build extension could not be resolved. + * @throws PluginResolutionException If any build extension could not be resolved. */ ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException, PluginVersionResolutionException; + throws PluginResolutionException, PluginVersionResolutionException; } diff --git a/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java b/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java index 496312cc2b..fc1d03732b 100644 --- a/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java +++ b/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java @@ -22,10 +22,8 @@ package org.apache.maven.project; import java.util.ArrayList; import java.util.List; -import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; 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.codehaus.plexus.component.annotations.Component; @@ -43,7 +41,6 @@ public class EmptyProjectBuildingHelper public List createArtifactRepositories( List pomRepositories, List externalRepositories, ProjectBuildingRequest request ) - throws InvalidRepositoryException { if ( externalRepositories != null ) { @@ -57,7 +54,6 @@ public class EmptyProjectBuildingHelper public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject proejct, Model model, RepositoryRequest repositoryRequest ) - throws ArtifactResolutionException { return new ProjectRealmCache.CacheRecord( null, null ); }