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