From c7e407ba128e2561006af7384ac22b73d91c00fd Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Thu, 21 Apr 2005 13:47:42 +0000 Subject: [PATCH] improve error handling for failed downloads git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164058 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/maven/DefaultMaven.java | 14 ++++++++++---- .../maven/project/DefaultMavenProjectBuilder.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 878fe6cb7f..8ab8fcd06b 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -20,6 +20,7 @@ package org.apache.maven; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenSession; @@ -246,7 +247,8 @@ public class DefaultMaven { if ( exception.getCause() == null ) { - logFailure( response, (PluginExecutionException) exception ); + PluginExecutionException e = (PluginExecutionException) exception; + logFailure( response, e, e.getLongMessage() ); } else { @@ -254,6 +256,10 @@ public class DefaultMaven logError( response ); } } + else if ( exception instanceof ArtifactResolutionException ) + { + logFailure( response, exception, null ); + } else { // TODO: this should be a "FATAL" exception, reported to the @@ -354,7 +360,7 @@ public class DefaultMaven line(); } - protected void logFailure( MavenExecutionResponse r, PluginExecutionException e ) + protected void logFailure( MavenExecutionResponse r, Throwable e, String longMessage ) { line(); @@ -366,9 +372,9 @@ public class DefaultMaven line(); - if ( e.getLongMessage() != null ) + if ( longMessage != null ) { - getLogger().info( e.getLongMessage() ); + getLogger().info( longMessage ); line(); } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index b31df3795c..5045b212cb 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -19,6 +19,7 @@ package org.apache.maven.project; import org.apache.maven.MavenConstants; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.MavenMetadataSource; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; @@ -178,7 +179,6 @@ public class DefaultMavenProjectBuilder ArtifactRepository localRepository ) throws ProjectBuildingException { - Settings settings = readSettings(); Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );