mirror of https://github.com/apache/maven.git
improved error handling for failed downloads
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6e310fbc3b
commit
804e18cac0
|
@ -1,5 +1,7 @@
|
|||
package org.apache.maven.artifact.resolver;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
|
@ -23,20 +25,51 @@ package org.apache.maven.artifact.resolver;
|
|||
public class ArtifactResolutionException
|
||||
extends Exception
|
||||
{
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
public ArtifactResolutionException( String message )
|
||||
private String version;
|
||||
|
||||
private String type;
|
||||
|
||||
public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, Throwable t )
|
||||
{
|
||||
super( message );
|
||||
super( "Unable to resolve artifact " + groupId + ":" + artifactId + ":" + version + ":" + type + "\n" + message, t );
|
||||
|
||||
this.groupId = groupId;
|
||||
this.artifactId = artifactId;
|
||||
this.type = type;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public ArtifactResolutionException( Throwable cause )
|
||||
public ArtifactResolutionException( String message, Artifact artifact, Throwable t )
|
||||
{
|
||||
super( cause );
|
||||
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), t );
|
||||
}
|
||||
|
||||
public ArtifactResolutionException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
}
|
||||
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,11 +128,11 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( artifactNotFound( localPath, remoteRepositories ), e );
|
||||
throw new ArtifactResolutionException( artifactNotFound( localPath, remoteRepositories ), artifact, e );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Error downloading artifact " + artifact, e );
|
||||
throw new ArtifactResolutionException( e.getMessage(), artifact, e );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
|
|
|
@ -95,10 +95,6 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
response.setException( e );
|
||||
}
|
||||
catch ( PluginNotFoundException e )
|
||||
{
|
||||
response.setException( e );
|
||||
}
|
||||
catch ( ArtifactHandlerNotFoundException e )
|
||||
{
|
||||
response.setException( e );
|
||||
|
@ -233,7 +229,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void processPluginConfiguration( MavenProject project, MavenSession mavenSession, Map phaseMap )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
throws LifecycleExecutionException, ArtifactResolutionException
|
||||
{
|
||||
for ( Iterator i = project.getPlugins().iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -251,7 +247,7 @@ public class DefaultLifecycleExecutor
|
|||
* @param session
|
||||
*/
|
||||
private void processPluginPhases( Plugin plugin, MavenSession session, Map phaseMap )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
throws LifecycleExecutionException, ArtifactResolutionException
|
||||
{
|
||||
String groupId = plugin.getGroupId();
|
||||
|
||||
|
@ -336,7 +332,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void processGoalChain( String task, MavenSession session, Map phaseMap )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
throws LifecycleExecutionException, ArtifactResolutionException
|
||||
{
|
||||
if ( phaseMap.containsKey( task ) )
|
||||
{
|
||||
|
@ -368,7 +364,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void verifyMojoPhase( String task, MavenSession session, Map phaseMap )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
throws LifecycleExecutionException, ArtifactResolutionException
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( task );
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public void verifyPluginForGoal( String goalName, MavenSession session )
|
||||
throws PluginNotFoundException, PluginManagerException
|
||||
throws ArtifactResolutionException, PluginManagerException
|
||||
{
|
||||
String pluginId = PluginDescriptor.getPluginIdFromGoal( goalName );
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public void verifyPlugin( String groupId, String artifactId, MavenSession session )
|
||||
throws PluginNotFoundException, PluginManagerException
|
||||
throws ArtifactResolutionException, PluginManagerException
|
||||
{
|
||||
if ( !isPluginInstalled( groupId, artifactId ) )
|
||||
{
|
||||
|
@ -258,7 +258,15 @@ public class DefaultPluginManager
|
|||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new PluginNotFoundException( groupId, artifactId, version, e );
|
||||
if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||
version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
|
||||
{
|
||||
throw new PluginNotFoundException( groupId, artifactId, version, e );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
|
|
|
@ -36,10 +36,10 @@ public interface PluginManager
|
|||
MojoDescriptor getMojoDescriptor( String goalId );
|
||||
|
||||
void verifyPluginForGoal( String goalName, MavenSession session )
|
||||
throws PluginNotFoundException, PluginManagerException;
|
||||
throws ArtifactResolutionException, PluginManagerException;
|
||||
|
||||
void verifyPlugin( String groupId, String artifactId, MavenSession session )
|
||||
throws PluginNotFoundException, PluginManagerException;
|
||||
throws ArtifactResolutionException, PluginManagerException;
|
||||
|
||||
PluginDescriptor getPluginDescriptor( String groupId, String artifactId );
|
||||
}
|
|
@ -25,12 +25,11 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class PluginNotFoundException
|
||||
extends Throwable
|
||||
extends ArtifactResolutionException
|
||||
{
|
||||
public PluginNotFoundException( String groupId, String artifactId, String version, ArtifactResolutionException e )
|
||||
{
|
||||
super(
|
||||
"Plugin could not found in any remote repositories: [" + groupId + ":" + artifactId + ":" + version + "]",
|
||||
e );
|
||||
super( "Plugin could not be found - check that the goal name is correct", groupId, artifactId, version,
|
||||
"maven-plugin", e );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue