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( "Missing:\n" );
88
89 buffer.append( "----------\n" );
90
91 int counter = 0;
92
93 for ( Artifact artifact : artifacts )
94 {
95 String message = ( ++counter ) + ") " + artifact.getId();
96
97 buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(),
98 artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(),
99 artifact.getDownloadUrl(), artifact.getDependencyTrail() ) );
100 }
101
102 buffer.append( "----------\n" );
103
104 int size = artifacts.size();
105
106 buffer.append( size ).append( " required artifact" );
107
108 if ( size > 1 )
109 {
110 buffer.append( "s are" );
111 }
112 else
113 {
114 buffer.append( " is" );
115 }
116
117 buffer.append( " missing.\n\nfor artifact: " );
118
119 return buffer.toString();
120 }
121
122 }