1   package org.apache.maven.artifact.ant;
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  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
25  
26  
27  
28  
29  
30  
31  
32  public class SpecificScopesArtifactFilter
33      implements ArtifactFilter
34  {
35      private boolean compileScope;
36  
37      private boolean runtimeScope;
38  
39      private boolean testScope;
40  
41      private boolean providedScope;
42  
43      private boolean systemScope;
44  
45      
46  
47  
48  
49  
50      public SpecificScopesArtifactFilter( String scopes )
51      {
52          String [] scopeList = scopes.split( "," );
53  
54          for ( int i = 0; i < scopeList.length; ++i )
55          {
56              String scope = scopeList[i].trim();
57  
58              if ( scope.equals( DefaultArtifact.SCOPE_COMPILE ) )
59              {
60                  compileScope = true;
61              }
62              else if ( scope.equals( DefaultArtifact.SCOPE_PROVIDED ) )
63              {
64                  providedScope = true;
65              }
66              else if ( scope.equals( DefaultArtifact.SCOPE_RUNTIME ) )
67              {
68                  runtimeScope = true;
69              }
70              else if ( scope.equals( DefaultArtifact.SCOPE_SYSTEM ) )
71              {
72                  systemScope = true;
73              }
74              else if ( scope.equals( DefaultArtifact.SCOPE_TEST ) )
75              {
76                  testScope = true;
77              }
78          }
79      }
80  
81      public boolean include( Artifact artifact )
82      {
83          if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
84          {
85              return compileScope;
86          }
87          else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
88          {
89              return runtimeScope;
90          }
91          else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
92          {
93              return testScope;
94          }
95          else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
96          {
97              return providedScope;
98          }
99          else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
100         {
101             return systemScope;
102         }
103         return true;
104     }
105 }