1 package org.apache.maven.usability; 2 3 18 19 import org.apache.maven.artifact.InvalidArtifactRTException; 20 import org.apache.maven.usability.diagnostics.ErrorDiagnoser; 21 22 public class InvalidArtifactDiagnoser 23 implements ErrorDiagnoser 24 { 25 26 public boolean canDiagnose( Throwable error ) 27 { 28 return error instanceof InvalidArtifactRTException; 29 } 30 31 public String diagnose( Throwable error ) 32 { 33 StringBuffer diagnosis = new StringBuffer (); 34 35 InvalidArtifactRTException e = (InvalidArtifactRTException) error; 36 37 diagnosis.append( "An invalid artifact was detected.\n\n" ) 38 .append( "This artifact might be in your project's POM, " ) 39 .append( "or it might have been included transitively during the resolution process. " ) 40 .append( "Here is the information we do have for this artifact:\n" ) 41 .append( "\n o GroupID: " ).append( maybeFlag( e.getGroupId() ) ) 42 .append( "\n o ArtifactID: " ).append( maybeFlag( e.getArtifactId() ) ) 43 .append( "\n o Version: " ).append( maybeFlag( e.getVersion() ) ) 44 .append( "\n o Type: " ).append( maybeFlag( e.getType() ) ) 45 .append( "\n" ); 46 47 return diagnosis.toString(); 48 } 49 50 private String maybeFlag( String value ) 51 { 52 if ( value == null || value.trim().length() < 1 ) 53 { 54 return "<<< MISSING >>>"; 55 } 56 else 57 { 58 return value; 59 } 60 } 61 62 } 63 | Popular Tags |