Package com.voltvoodoo.brew.compile

Source Code of com.voltvoodoo.brew.compile.FileTreeCompiler

package com.voltvoodoo.brew.compile;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.codehaus.plexus.util.DirectoryScanner;

import com.google.common.collect.Lists;

public class FileTreeCompiler {

    Map<String, Compiler> compilers = new TreeMap<String,Compiler>();
   
    public void addDefinition(String filePattern, Compiler compiler) {  
        compilers.put(filePattern, compiler);
    }

    public void compile(List<File> sourceDirs, File outputDir)
    {
        for(String pattern : compilers.keySet() )
        {
            for(File sourceDir : sourceDirs) {
                compile(pattern, sourceDir, outputDir, compilers.get(pattern));
            }
        }
    }

    private void compile(String pattern, File sourceDir, File outputDir, Compiler compiler) {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(sourceDir);
        scanner.setIncludes(new String[]{ pattern });
       
        scanner.scan();
        compiler.compile(Lists.newArrayList(scanner.getIncludedFiles()), sourceDir, outputDir);
    }
}
TOP

Related Classes of com.voltvoodoo.brew.compile.FileTreeCompiler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.