1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.project;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.IdentityHashMap;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.eclipse.aether.graph.Dependency;
28 import org.eclipse.aether.graph.DependencyNode;
29
30
31
32 class DefaultDependencyResolutionResult implements DependencyResolutionResult {
33
34 private DependencyNode root;
35
36 private List<Dependency> dependencies = new ArrayList<>();
37
38 private List<Dependency> resolvedDependencies = new ArrayList<>();
39
40 private List<Dependency> unresolvedDependencies = new ArrayList<>();
41
42 private List<Exception> collectionErrors = new ArrayList<>();
43
44 private Map<Dependency, List<Exception>> resolutionErrors = new IdentityHashMap<>();
45
46 public DependencyNode getDependencyGraph() {
47 return root;
48 }
49
50 public void setDependencyGraph(DependencyNode root) {
51 this.root = root;
52 }
53
54 public List<Dependency> getDependencies() {
55 return dependencies;
56 }
57
58 public List<Dependency> getResolvedDependencies() {
59 return resolvedDependencies;
60 }
61
62 public void addResolvedDependency(Dependency dependency) {
63 dependencies.add(dependency);
64 resolvedDependencies.add(dependency);
65 }
66
67 public List<Dependency> getUnresolvedDependencies() {
68 return unresolvedDependencies;
69 }
70
71 public List<Exception> getCollectionErrors() {
72 return collectionErrors;
73 }
74
75 public void setCollectionErrors(List<Exception> exceptions) {
76 if (exceptions != null) {
77 this.collectionErrors = exceptions;
78 } else {
79 this.collectionErrors = new ArrayList<>();
80 }
81 }
82
83 public List<Exception> getResolutionErrors(Dependency dependency) {
84 List<Exception> errors = resolutionErrors.get(dependency);
85 return (errors != null) ? Collections.unmodifiableList(errors) : Collections.emptyList();
86 }
87
88 public void setResolutionErrors(Dependency dependency, List<Exception> errors) {
89 dependencies.add(dependency);
90 unresolvedDependencies.add(dependency);
91 resolutionErrors.put(dependency, errors);
92 }
93 }