1 package org.apache.maven.artifact.resolver.filter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.artifact.DefaultArtifact;
24
25
26
27
28
29
30
31 public class ScopeArtifactFilter
32 implements ArtifactFilter
33 {
34 private final boolean compileScope;
35
36 private final boolean runtimeScope;
37
38 private final boolean testScope;
39
40 private final boolean providedScope;
41
42 private final boolean systemScope;
43
44 public ScopeArtifactFilter( String scope )
45 {
46 if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) )
47 {
48 systemScope = true;
49 providedScope = true;
50 compileScope = true;
51 runtimeScope = false;
52 testScope = false;
53 }
54 else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) )
55 {
56 systemScope = false;
57 providedScope = false;
58 compileScope = true;
59 runtimeScope = true;
60 testScope = false;
61 }
62 else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) )
63 {
64 systemScope = true;
65 providedScope = true;
66 compileScope = true;
67 runtimeScope = true;
68 testScope = true;
69 }
70 else
71 {
72 systemScope = false;
73 providedScope = false;
74 compileScope = false;
75 runtimeScope = false;
76 testScope = false;
77 }
78 }
79
80 public boolean include( Artifact artifact )
81 {
82 if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
83 {
84 return compileScope;
85 }
86 else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
87 {
88 return runtimeScope;
89 }
90 else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
91 {
92 return testScope;
93 }
94 else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
95 {
96 return providedScope;
97 }
98 else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
99 {
100 return systemScope;
101 }
102 else
103 {
104 return true;
105 }
106 }
107 }