Search in sources :

Example 11 with SourceFileScanner

use of org.apache.tools.ant.util.SourceFileScanner in project jangaroo-tools by CoreMedia.

the class ExmlcTask method scanDir.

/**
 * Scans the directory looking for source files to be compiled.
 * The results are returned in the class variable compileList
 *
 * @param srcDir  the source directory
 * @param destDir the destination directory
 * @param files   the files to scan
 */
protected void scanDir(File srcDir, File destDir, String[] files) {
    GlobPatternMapper m = new GlobPatternMapper();
    m.setFrom("*.exml");
    m.setTo("*.as");
    SourceFileScanner sfs = new SourceFileScanner(this);
    File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
    if (newFiles.length > 0) {
        File[] newCompileList = new File[compileList.length + newFiles.length];
        System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
        System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length);
        compileList = newCompileList;
    }
}
Also used : GlobPatternMapper(org.apache.tools.ant.util.GlobPatternMapper) SourceFileScanner(org.apache.tools.ant.util.SourceFileScanner) File(java.io.File)

Example 12 with SourceFileScanner

use of org.apache.tools.ant.util.SourceFileScanner in project jangaroo-tools by CoreMedia.

the class JoocTask method scanDir.

/**
 * Scans the directory looking for source files to be compiled.
 * The results are returned in the class variable compileList
 *
 * @param srcDir  the source directory
 * @param destDir the destination directory
 * @param files   the files to scan
 */
protected void scanDir(File srcDir, File destDir, String[] files) {
    GlobPatternMapper m = new GlobPatternMapper();
    m.setFrom("*" + Jooc.INPUT_FILE_SUFFIX);
    m.setTo("*.js");
    SourceFileScanner sfs = new SourceFileScanner(this);
    File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
    if (newFiles.length > 0) {
        File[] newCompileList = new File[compileList.length + newFiles.length];
        System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
        System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length);
        compileList = newCompileList;
    }
}
Also used : GlobPatternMapper(org.apache.tools.ant.util.GlobPatternMapper) SourceFileScanner(org.apache.tools.ant.util.SourceFileScanner) File(java.io.File)

Example 13 with SourceFileScanner

use of org.apache.tools.ant.util.SourceFileScanner in project groovy-core by groovy.

the class GroovycTask method compile.

protected void compile() {
    Path path = getClasspath();
    if (path != null) {
        config.setClasspath(path.toString());
    }
    config.setTargetDirectory(destdir);
    GroovyClassLoader gcl = createClassLoader();
    CompilationUnit compilation = new CompilationUnit(config, null, gcl);
    GlobPatternMapper mapper = new GlobPatternMapper();
    mapper.setFrom("*.groovy");
    mapper.setTo("*.class");
    int count = 0;
    String[] list = src.list();
    for (int i = 0; i < list.length; i++) {
        File basedir = getProject().resolveFile(list[i]);
        if (!basedir.exists()) {
            throw new BuildException("Source directory does not exist: " + basedir, getLocation());
        }
        DirectoryScanner scanner = getDirectoryScanner(basedir);
        String[] includes = scanner.getIncludedFiles();
        if (force) {
            log.debug("Forcefully including all files from: " + basedir);
            for (int j = 0; j < includes.length; j++) {
                File file = new File(basedir, includes[j]);
                log.debug("    " + file);
                compilation.addSource(file);
                count++;
            }
        } else {
            log.debug("Including changed files from: " + basedir);
            SourceFileScanner sourceScanner = new SourceFileScanner(this);
            File[] files = sourceScanner.restrictAsFiles(includes, basedir, destdir, mapper);
            for (int j = 0; j < files.length; j++) {
                log.debug("    " + files[j]);
                compilation.addSource(files[j]);
                count++;
            }
        }
    }
    if (count > 0) {
        log.info("Compiling " + count + " source file" + (count > 1 ? "s" : "") + " to " + destdir);
        compilation.compile();
    } else {
        log.info("No sources found to compile");
    }
}
Also used : Path(org.apache.tools.ant.types.Path) GroovyClassLoader(groovy.lang.GroovyClassLoader) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) GlobPatternMapper(org.apache.tools.ant.util.GlobPatternMapper) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) SourceFileScanner(org.apache.tools.ant.util.SourceFileScanner) File(java.io.File)

Example 14 with SourceFileScanner

use of org.apache.tools.ant.util.SourceFileScanner in project groovy-core by groovy.

the class Groovyc method scanDir.

/**
 * Scans the directory looking for source files to be compiled.
 * The results are returned in the class variable compileList
 *
 * @param srcDir  The source directory
 * @param destDir The destination directory
 * @param files   An array of filenames
 */
protected void scanDir(File srcDir, File destDir, String[] files) {
    GlobPatternMapper m = new GlobPatternMapper();
    SourceFileScanner sfs = new SourceFileScanner(this);
    File[] newFiles;
    for (String extension : getScriptExtensions()) {
        m.setFrom("*." + extension);
        m.setTo("*.class");
        newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
        addToCompileList(newFiles);
    }
    if (jointCompilation) {
        m.setFrom("*.java");
        m.setTo("*.class");
        newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
        addToCompileList(newFiles);
    }
}
Also used : GlobPatternMapper(org.apache.tools.ant.util.GlobPatternMapper) SourceFileScanner(org.apache.tools.ant.util.SourceFileScanner) File(java.io.File)

Aggregations

SourceFileScanner (org.apache.tools.ant.util.SourceFileScanner)14 File (java.io.File)11 GlobPatternMapper (org.apache.tools.ant.util.GlobPatternMapper)8 BuildException (org.apache.tools.ant.BuildException)5 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)5 Path (org.apache.tools.ant.types.Path)3 FileNameMapper (org.apache.tools.ant.util.FileNameMapper)3 GroovyClassLoader (groovy.lang.GroovyClassLoader)2 Vector (java.util.Vector)2 CompilationUnit (org.codehaus.groovy.control.CompilationUnit)2 IOException (java.io.IOException)1 Remote (java.rmi.Remote)1 Stream (java.util.stream.Stream)1 AntClassLoader (org.apache.tools.ant.AntClassLoader)1 Project (org.apache.tools.ant.Project)1 RmicAdapter (org.apache.tools.ant.taskdefs.rmic.RmicAdapter)1 RmicAdapterFactory (org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory)1 FileSet (org.apache.tools.ant.types.FileSet)1 FilterSetCollection (org.apache.tools.ant.types.FilterSetCollection)1 Reference (org.apache.tools.ant.types.Reference)1