1 package org.apache.maven.report.projectinfo.dependencies;
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.HashMap;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.apache.maven.artifact.Artifact;
29 import org.apache.maven.model.Dependency;
30
31
32
33
34
35
36 public class ManagementDependencies
37 {
38 private final List managementDependencies;
39
40
41
42
43 public ManagementDependencies( List projectDependencies )
44 {
45 this.managementDependencies = projectDependencies;
46 }
47
48
49
50
51 public boolean hasDependencies()
52 {
53 return ( managementDependencies != null ) && ( !this.managementDependencies.isEmpty() );
54 }
55
56
57
58
59 public List getManagementDependencies()
60 {
61 return new ArrayList( managementDependencies );
62 }
63
64
65
66
67
68
69
70
71
72 public Map getManagementDependenciesByScope()
73 {
74 Map dependenciesByScope = new HashMap();
75 for ( Iterator i = getManagementDependencies().iterator(); i.hasNext(); )
76 {
77 Dependency dependency = (Dependency) i.next();
78 String scope = dependency.getScope() != null ? dependency.getScope() : Artifact.SCOPE_COMPILE;
79 List multiValue = (List) dependenciesByScope.get( scope );
80 if ( multiValue == null )
81 {
82 multiValue = new ArrayList();
83 }
84 multiValue.add( dependency );
85 dependenciesByScope.put( scope, multiValue );
86 }
87
88 return dependenciesByScope;
89 }
90 }