1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.ant.tasks.support;
20
21 import org.apache.maven.artifact.Artifact;
22 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
23
24
25
26
27
28
29 public class SpecificScopesArtifactFilter implements ArtifactFilter {
30 private boolean compileScope;
31
32 private boolean runtimeScope;
33
34 private boolean testScope;
35
36 private boolean providedScope;
37
38 private boolean systemScope;
39
40
41
42
43
44
45 public SpecificScopesArtifactFilter(String scopes) {
46 String[] scopeList = scopes.split(",");
47
48 for (String aScopeList : scopeList) {
49 if (aScopeList.trim().equals(Artifact.SCOPE_COMPILE)) {
50 compileScope = true;
51 } else if (aScopeList.trim().equals(Artifact.SCOPE_PROVIDED)) {
52 providedScope = true;
53 } else if (aScopeList.trim().equals(Artifact.SCOPE_RUNTIME)) {
54 runtimeScope = true;
55 } else if (aScopeList.trim().equals(Artifact.SCOPE_SYSTEM)) {
56 systemScope = true;
57 } else if (aScopeList.trim().equals(Artifact.SCOPE_TEST)) {
58 testScope = true;
59 }
60 }
61 }
62
63
64 @Override
65 public boolean include(Artifact artifact) {
66 if (Artifact.SCOPE_COMPILE.equals(artifact.getScope())) {
67 return compileScope;
68 } else if (Artifact.SCOPE_RUNTIME.equals(artifact.getScope())) {
69 return runtimeScope;
70 } else if (Artifact.SCOPE_TEST.equals(artifact.getScope())) {
71 return testScope;
72 } else if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
73 return providedScope;
74 } else if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
75 return systemScope;
76 } else {
77 return true;
78 }
79 }
80 }