add artifact not found diagnoser

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-07 07:19:32 +00:00
parent 3ad9ca72c5
commit 6e0a157eb3
4 changed files with 80 additions and 5 deletions

View File

@ -0,0 +1,61 @@
package org.apache.maven.usability;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
public class ArtifactNotFoundDiagnoser
implements ErrorDiagnoser
{
private WagonManager wagonManager;
public boolean canDiagnose( Throwable error )
{
return DiagnosisUtils.containsInCausality( error, ArtifactNotFoundException.class );
}
public String diagnose( Throwable error )
{
ArtifactNotFoundException exception = (ArtifactNotFoundException) DiagnosisUtils.getFromCausality( error,
ArtifactNotFoundException.class );
StringBuffer message = new StringBuffer();
message.append( "Failed to resolve artifact." );
message.append( "\n\n" );
message.append( exception.getMessage() );
if ( !wagonManager.isOnline() )
{
message.append( "\n" ).append( DiagnosisUtils.getOfflineWarning() );
}
Throwable root = DiagnosisUtils.getRootCause( exception );
if ( root != null )
{
message.append( "\nRoot Cause: " ).append( root.getMessage() );
}
message.append( "\n" );
return message.toString();
}
}

View File

@ -17,7 +17,6 @@ package org.apache.maven.usability;
*/ */
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
public class ArtifactResolverDiagnoser public class ArtifactResolverDiagnoser
@ -28,13 +27,13 @@ public class ArtifactResolverDiagnoser
public boolean canDiagnose( Throwable error ) public boolean canDiagnose( Throwable error )
{ {
return DiagnosisUtils.containsInCausality( error, AbstractArtifactResolutionException.class ); return DiagnosisUtils.containsInCausality( error, ArtifactResolutionException.class );
} }
public String diagnose( Throwable error ) public String diagnose( Throwable error )
{ {
AbstractArtifactResolutionException exception = (AbstractArtifactResolutionException) DiagnosisUtils.getFromCausality( ArtifactResolutionException exception = (ArtifactResolutionException) DiagnosisUtils.getFromCausality( error,
error, ArtifactResolutionException.class ); ArtifactResolutionException.class );
StringBuffer message = new StringBuffer(); StringBuffer message = new StringBuffer();

View File

@ -121,6 +121,21 @@
<role-hint>PluginContainerDiagnoser</role-hint> <role-hint>PluginContainerDiagnoser</role-hint>
<implementation>org.apache.maven.usability.PluginContainerDiagnoser</implementation> <implementation>org.apache.maven.usability.PluginContainerDiagnoser</implementation>
</component> </component>
<!--
|
|ArtifactNotFoundDiagnoser
|
-->
<component>
<role>org.apache.maven.usability.ErrorDiagnoser</role>
<role-hint>ArtifactNotFoundDiagnoser</role-hint>
<implementation>org.apache.maven.usability.ArtifactNotFoundDiagnoser</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
</requirements>
</component>
<!-- <!--
| |
|ArtifactResolverDiagnoser |ArtifactResolverDiagnoser

View File

@ -57,7 +57,7 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-java</artifactId> <artifactId>maven-plugin-tools-java</artifactId>
<version>2.0-beta-3</version> <version>2.0-beta-4-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>