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