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