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 this( originatingArtifact, new ArrayList(), missingArtifacts, remoteRepositories );
44 }
45
46
47
48
49
50
51
52
53
54 public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List resolvedArtifacts,
55 List missingArtifacts, List remoteRepositories )
56 {
57 super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories );
58 this.resolvedArtifacts = resolvedArtifacts;
59 this.missingArtifacts = missingArtifacts;
60 }
61
62
63
64
65
66 public List getResolvedArtifacts()
67 {
68 return resolvedArtifacts;
69 }
70
71
72
73
74
75 public List getMissingArtifacts()
76 {
77 return missingArtifacts;
78 }
79
80 private static String constructMessage( List artifacts )
81 {
82 StringBuffer buffer = new StringBuffer( "Missing:\n" );
83
84 buffer.append( "----------\n" );
85
86 int counter = 0;
87
88 for ( Iterator i = artifacts.iterator(); i.hasNext(); )
89 {
90 Artifact artifact = (Artifact) i.next();
91 String message = ( ++counter ) + ") " + artifact.getId();
92
93 buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact
94 .getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact
95 .getDependencyTrail() ) );
96 }
97
98 buffer.append( "----------\n" );
99
100 int size = artifacts.size();
101
102 buffer.append( size ).append( " required artifact" );
103
104 if ( size > 1 )
105 {
106 buffer.append( "s are" );
107 }
108 else
109 {
110 buffer.append( " is" );
111 }
112
113 buffer.append( " missing.\n\nfor artifact: " );
114
115 return buffer.toString();
116 }
117
118 }