use of org.apache.tools.ant.util.GlobPatternMapper in project groovy by apache.
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);
}
}
use of org.apache.tools.ant.util.GlobPatternMapper in project groovy by apache.
the class GroovycTask method compile.
@Override
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 (String s : list) {
File basedir = getProject().resolveFile(s);
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 (String include : includes) {
File file = new File(basedir, include);
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 (File file : files) {
log.debug(" " + file);
compilation.addSource(file);
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");
}
}
use of org.apache.tools.ant.util.GlobPatternMapper 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;
}
}
use of org.apache.tools.ant.util.GlobPatternMapper 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;
}
}
use of org.apache.tools.ant.util.GlobPatternMapper 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");
}
}
Aggregations