Coverage Report - org.apache.maven.shared.io.scan.AbstractResourceInclusionScanner
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractResourceInclusionScanner
0%
0/19
0%
0/2
1.667
 
 1  
 package org.apache.maven.shared.io.scan;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.maven.shared.io.scan.mapping.SourceMapping;
 20  
 import org.codehaus.plexus.util.DirectoryScanner;
 21  
 
 22  
 import java.io.File;
 23  
 import java.util.ArrayList;
 24  
 import java.util.Collections;
 25  
 import java.util.List;
 26  
 import java.util.Set;
 27  
 
 28  
 /**
 29  
  * @author jdcasey
 30  
  * @version $Id: org.apache.maven.shared.io.scan.AbstractResourceInclusionScanner.html 2271 2006-08-22 15:19:41Z joakime $
 31  
  */
 32  0
 public abstract class AbstractResourceInclusionScanner
 33  
     implements ResourceInclusionScanner
 34  
 {
 35  0
     private final List sourceMappings = new ArrayList();
 36  
 
 37  
     public final void addSourceMapping( SourceMapping sourceMapping )
 38  
     {
 39  0
         sourceMappings.add( sourceMapping );
 40  0
     }
 41  
 
 42  
     protected final List getSourceMappings()
 43  
     {
 44  0
         return Collections.unmodifiableList( sourceMappings );
 45  
     }
 46  
 
 47  
     protected String[] scanForSources( File sourceDir, Set sourceIncludes, Set sourceExcludes )
 48  
     {
 49  0
         DirectoryScanner ds = new DirectoryScanner();
 50  0
         ds.setFollowSymlinks( true );
 51  0
         ds.setBasedir( sourceDir );
 52  
 
 53  
         String[] includes;
 54  0
         if ( sourceIncludes.isEmpty() )
 55  
         {
 56  0
             includes = new String[0];
 57  
         }
 58  
         else
 59  
         {
 60  0
             includes = (String[]) sourceIncludes.toArray( new String[sourceIncludes.size()] );
 61  
         }
 62  
 
 63  0
         ds.setIncludes( includes );
 64  
 
 65  
         String[] excludes;
 66  0
         if ( sourceExcludes.isEmpty() )
 67  
         {
 68  0
             excludes = new String[0];
 69  
         }
 70  
         else
 71  
         {
 72  0
             excludes = (String[]) sourceExcludes.toArray( new String[sourceExcludes.size()] );
 73  
         }
 74  
 
 75  0
         ds.setExcludes( excludes );
 76  0
         ds.addDefaultExcludes();
 77  
 
 78  0
         ds.scan();
 79  
 
 80  0
         return ds.getIncludedFiles();
 81  
     }
 82  
 }