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