1 package org.apache.maven.shared.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.Collection;
23
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
26
27
28
29
30
31
32
33
34
35
36
37 final class CumulativeScopeArtifactFilter
38 implements ArtifactFilter
39 {
40 private boolean compileScope;
41
42 private boolean runtimeScope;
43
44 private boolean testScope;
45
46 private boolean providedScope;
47
48 private boolean systemScope;
49
50
51
52
53 CumulativeScopeArtifactFilter()
54 {
55 }
56
57
58
59
60
61 CumulativeScopeArtifactFilter( String scope )
62 {
63 addScope( scope );
64 }
65
66
67
68
69
70
71 CumulativeScopeArtifactFilter( Collection<String> scopes )
72 {
73 if ( scopes != null )
74 {
75 for ( String scope : scopes )
76 {
77 addScope( scope );
78 }
79 }
80 }
81
82
83
84
85
86 void addScope( String scope )
87 {
88 if ( Artifact.SCOPE_COMPILE.equals( scope ) )
89 {
90 systemScope = true;
91 providedScope = true;
92 compileScope = true;
93 }
94 else if ( Artifact.SCOPE_RUNTIME.equals( scope ) )
95 {
96 compileScope = true;
97 runtimeScope = true;
98 }
99 else if ( Artifact.SCOPE_TEST.equals( scope ) )
100 {
101 systemScope = true;
102 providedScope = true;
103 compileScope = true;
104 runtimeScope = true;
105 testScope = true;
106 }
107 else if ( Artifact.SCOPE_PROVIDED.equals( scope ) )
108 {
109 providedScope = true;
110 }
111 }
112
113
114
115
116 public boolean include( Artifact artifact )
117 {
118 if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
119 {
120 return compileScope;
121 }
122 else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
123 {
124 return runtimeScope;
125 }
126 else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
127 {
128 return testScope;
129 }
130 else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
131 {
132 return providedScope;
133 }
134 else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
135 {
136 return systemScope;
137 }
138 else
139 {
140 return true;
141 }
142 }
143 }