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
33 class DefaultDependencyResolutionResult implements DependencyResolutionResult {
34
35 private DependencyNode root;
36
37 private List<Dependency> dependencies = new ArrayList<>();
38
39 private List<Dependency> resolvedDependencies = new ArrayList<>();
40
41 private List<Dependency> unresolvedDependencies = new ArrayList<>();
42
43 private List<Exception> collectionErrors = new ArrayList<>();
44
45 private Map<Dependency, List<Exception>> resolutionErrors = new IdentityHashMap<>();
46
47 public DependencyNode getDependencyGraph() {
48 return root;
49 }
50
51 public void setDependencyGraph(DependencyNode root) {
52 this.root = root;
53 }
54
55 public List<Dependency> getDependencies() {
56 return dependencies;
57 }
58
59 public List<Dependency> getResolvedDependencies() {
60 return resolvedDependencies;
61 }
62
63 public void addResolvedDependency(Dependency dependency) {
64 dependencies.add(dependency);
65 resolvedDependencies.add(dependency);
66 }
67
68 public List<Dependency> getUnresolvedDependencies() {
69 return unresolvedDependencies;
70 }
71
72 public List<Exception> getCollectionErrors() {
73 return collectionErrors;
74 }
75
76 public void setCollectionErrors(List<Exception> exceptions) {
77 if (exceptions != null) {
78 this.collectionErrors = exceptions;
79 } else {
80 this.collectionErrors = new ArrayList<>();
81 }
82 }
83
84 public List<Exception> getResolutionErrors(Dependency dependency) {
85 List<Exception> errors = resolutionErrors.get(dependency);
86 return (errors != null) ? Collections.unmodifiableList(errors) : Collections.emptyList();
87 }
88
89 public void setResolutionErrors(Dependency dependency, List<Exception> errors) {
90 dependencies.add(dependency);
91 unresolvedDependencies.add(dependency);
92 resolutionErrors.put(dependency, errors);
93 }
94 }