1 package org.apache.maven.artifact.resolver; 2 3 import java.util.Iterator ; 4 import java.util.List ; 5 6 import org.apache.maven.artifact.Artifact; 7 8 public class MultipleArtifactsNotFoundException 9 extends ArtifactResolutionException 10 { 11 12 public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List artifacts, List remoteRepositories ) 13 { 14 super( constructMessage( artifacts ), originatingArtifact, remoteRepositories ); 15 } 16 17 private static String constructMessage( List artifacts ) 18 { 19 StringBuffer buffer = new StringBuffer ( "Missing:\n" ); 20 21 buffer.append( "----------\n" ); 22 23 int counter = 0; 24 25 for ( Iterator i = artifacts.iterator(); i.hasNext(); ) 26 { 27 Artifact artifact = (Artifact) i.next(); 28 String message = ( ++counter ) + ") " + artifact.getId(); 29 30 buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact 31 .getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getDownloadUrl(), artifact 32 .getDependencyTrail() ) ); 33 } 34 35 buffer.append( "----------\n" ); 36 37 int size = artifacts.size(); 38 39 buffer.append( size ).append( " required artifact" ); 40 41 if ( size > 1 ) 42 { 43 buffer.append( "s are" ); 44 } 45 else 46 { 47 buffer.append( " is" ); 48 } 49 50 buffer.append( " missing.\n\nfor artifact: " ); 51 52 return buffer.toString(); 53 } 54 55 } 56 | Popular Tags |