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