001    package org.apache.myfaces.maven.plugin;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    import org.codehaus.plexus.compiler.util.scan.AbstractSourceInclusionScanner;
021    import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
022    
023    import java.io.File;
024    import java.util.HashSet;
025    import java.util.Set;
026    
027    /**
028     * 
029     */
030    public class AllSourcesInclusionScanner extends AbstractSourceInclusionScanner
031    {
032        /**
033         *
034         */
035        private Set sourceIncludes;
036        /**
037         *
038         */
039        private Set sourceExcludes;
040    
041        /**
042         *
043         * @param sourceIncludeSet
044         * @param sourceExcludeSet
045         */
046        public AllSourcesInclusionScanner( Set sourceIncludeSet,
047                                           Set sourceExcludeSet )
048        {
049            this.sourceIncludes = sourceIncludeSet;
050            this.sourceExcludes = sourceExcludeSet;
051        }
052    
053        /**
054         *
055         * @param sourceDir
056         * @param targetDir
057         * @return
058         * @throws InclusionScanException
059         */
060        public Set getIncludedSources( File sourceDir, File targetDir )
061            throws InclusionScanException
062        {
063            String[] sourceNames = scanForSources( sourceDir, sourceIncludes, sourceExcludes );
064            Set sources = new HashSet();
065            for ( int i = 0; i < sourceNames.length; i++ )
066            {
067                String path = sourceNames[i];
068                File sourceFile = new File( sourceDir, path );
069                sources.add( sourceFile );
070            }
071            return sources;
072        }
073    }