| 1 | |
package org.apache.maven.artifact.resolver; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
import java.util.ArrayList; |
| 23 | |
import java.util.Iterator; |
| 24 | |
import java.util.List; |
| 25 | |
|
| 26 | |
import org.apache.maven.artifact.Artifact; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
public class MultipleArtifactsNotFoundException |
| 33 | |
extends ArtifactResolutionException |
| 34 | |
{ |
| 35 | |
private final List resolvedArtifacts; |
| 36 | |
private final List missingArtifacts; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List missingArtifacts, List remoteRepositories ) |
| 42 | |
{ |
| 43 | 0 | this( originatingArtifact, new ArrayList(), missingArtifacts, remoteRepositories ); |
| 44 | 0 | } |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List resolvedArtifacts, |
| 55 | |
List missingArtifacts, List remoteRepositories ) |
| 56 | |
{ |
| 57 | 0 | super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories ); |
| 58 | 0 | this.resolvedArtifacts = resolvedArtifacts; |
| 59 | 0 | this.missingArtifacts = missingArtifacts; |
| 60 | 0 | } |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
public List getResolvedArtifacts() |
| 67 | |
{ |
| 68 | 0 | return resolvedArtifacts; |
| 69 | |
} |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
public List getMissingArtifacts() |
| 76 | |
{ |
| 77 | 0 | return missingArtifacts; |
| 78 | |
} |
| 79 | |
|
| 80 | |
private static String constructMessage( List artifacts ) |
| 81 | |
{ |
| 82 | 0 | StringBuffer buffer = new StringBuffer( "Missing:\n" ); |
| 83 | |
|
| 84 | 0 | buffer.append( "----------\n" ); |
| 85 | |
|
| 86 | 0 | int counter = 0; |
| 87 | |
|
| 88 | 0 | for ( Iterator i = artifacts.iterator(); i.hasNext(); ) |
| 89 | |
{ |
| 90 | 0 | Artifact artifact = (Artifact) i.next(); |
| 91 | 0 | String message = ( ++counter ) + ") " + artifact.getId(); |
| 92 | |
|
| 93 | 0 | buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact |
| 94 | |
.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact |
| 95 | |
.getDependencyTrail() ) ); |
| 96 | 0 | } |
| 97 | |
|
| 98 | 0 | buffer.append( "----------\n" ); |
| 99 | |
|
| 100 | 0 | int size = artifacts.size(); |
| 101 | |
|
| 102 | 0 | buffer.append( size ).append( " required artifact" ); |
| 103 | |
|
| 104 | 0 | if ( size > 1 ) |
| 105 | |
{ |
| 106 | 0 | buffer.append( "s are" ); |
| 107 | |
} |
| 108 | |
else |
| 109 | |
{ |
| 110 | 0 | buffer.append( " is" ); |
| 111 | |
} |
| 112 | |
|
| 113 | 0 | buffer.append( " missing.\n\nfor artifact: " ); |
| 114 | |
|
| 115 | 0 | return buffer.toString(); |
| 116 | |
} |
| 117 | |
|
| 118 | |
} |