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.List;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.artifact.repository.ArtifactRepository;
27
28
29
30
31
32 public class MultipleArtifactsNotFoundException
33 extends ArtifactResolutionException
34 {
35 private final List<Artifact> resolvedArtifacts;
36 private final List<Artifact> missingArtifacts;
37
38
39 @Deprecated
40 public MultipleArtifactsNotFoundException( Artifact originatingArtifact,
41 List<Artifact> missingArtifacts,
42 List<ArtifactRepository> remoteRepositories )
43 {
44 this( originatingArtifact, new ArrayList<Artifact>(), missingArtifacts, remoteRepositories );
45 }
46
47
48
49
50
51
52
53
54
55 public MultipleArtifactsNotFoundException( Artifact originatingArtifact,
56 List<Artifact> resolvedArtifacts,
57 List<Artifact> missingArtifacts,
58 List<ArtifactRepository> remoteRepositories )
59 {
60 super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories );
61 this.resolvedArtifacts = resolvedArtifacts;
62 this.missingArtifacts = missingArtifacts;
63 }
64
65
66
67
68
69
70 public List<Artifact> getResolvedArtifacts()
71 {
72 return resolvedArtifacts;
73 }
74
75
76
77
78
79
80 public List<Artifact> getMissingArtifacts()
81 {
82 return missingArtifacts;
83 }
84
85 private static String constructMessage( List<Artifact> artifacts )
86 {
87 StringBuilder buffer = new StringBuilder( 256 );
88
89 buffer.append( "Missing:\n" );
90 buffer.append( "----------\n" );
91
92 int counter = 0;
93
94 for ( Artifact artifact : artifacts )
95 {
96 String message = ( ++counter ) + ") " + artifact.getId();
97
98 buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(),
99 artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(),
100 artifact.getDownloadUrl(), artifact.getDependencyTrail() ) );
101 }
102
103 buffer.append( "----------\n" );
104
105 int size = artifacts.size();
106
107 buffer.append( size ).append( " required artifact" );
108
109 if ( size > 1 )
110 {
111 buffer.append( "s are" );
112 }
113 else
114 {
115 buffer.append( " is" );
116 }
117
118 buffer.append( " missing.\n\nfor artifact: " );
119
120 return buffer.toString();
121 }
122
123 }