1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.report.projectinfo.dependencies;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.maven.artifact.Artifact;
27 import org.apache.maven.model.Dependency;
28
29
30
31
32
33 public class ManagementDependencies {
34 private final List<Dependency> dependencies;
35
36
37
38
39 public ManagementDependencies(List<Dependency> projectDependencies) {
40 this.dependencies = projectDependencies;
41 }
42
43
44
45
46 public boolean hasDependencies() {
47 return (dependencies != null) && (!this.dependencies.isEmpty());
48 }
49
50
51
52
53 public List<Dependency> getManagementDependencies() {
54 return new ArrayList<>(dependencies);
55 }
56
57
58
59
60
61
62
63
64
65 public Map<String, List<Dependency>> getManagementDependenciesByScope() {
66 Map<String, List<Dependency>> dependenciesByScope = new HashMap<>();
67 for (Dependency dependency : dependencies) {
68 String scope = dependency.getScope() != null ? dependency.getScope() : Artifact.SCOPE_COMPILE;
69 List<Dependency> multiValue = dependenciesByScope.get(scope);
70 if (multiValue == null) {
71 multiValue = new ArrayList<>();
72 }
73 multiValue.add(dependency);
74 dependenciesByScope.put(scope, multiValue);
75 }
76
77 return dependenciesByScope;
78 }
79 }