use of org.apache.tools.ant.DirectoryScanner in project jetty.project by eclipse.
the class FileMatchingConfiguration method isIncluded.
/**
* Checks if passed file is scanned by any of the directory scanners.
*
* @param pathToFile a fully qualified path to tested file.
* @return true if so, false otherwise.
*/
public boolean isIncluded(String pathToFile) {
Iterator scanners = directoryScanners.iterator();
while (scanners.hasNext()) {
DirectoryScanner scanner = (DirectoryScanner) scanners.next();
scanner.scan();
String[] includedFiles = scanner.getIncludedFiles();
for (int i = 0; i < includedFiles.length; i++) {
File includedFile = new File(scanner.getBasedir(), includedFiles[i]);
if (pathToFile.equalsIgnoreCase(includedFile.getAbsolutePath())) {
return true;
}
}
}
return false;
}
use of org.apache.tools.ant.DirectoryScanner in project cglib by cglib.
the class AbstractProcessTask method getFiles.
protected Collection getFiles() {
Map fileMap = new HashMap();
Project p = getProject();
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(p);
String[] srcFiles = ds.getIncludedFiles();
File dir = fs.getDir(p);
for (int j = 0; j < srcFiles.length; j++) {
File src = new File(dir, srcFiles[j]);
fileMap.put(src.getAbsolutePath(), src);
}
}
return fileMap.values();
}
use of org.apache.tools.ant.DirectoryScanner in project quasar by puniverse.
the class InstrumentationTask method execute.
@Override
public void execute() throws BuildException {
try {
final List<URL> urls = new ArrayList<>();
for (FileSet fs : filesets) urls.add(fs.getDir().toURI().toURL());
final ClassLoader cl = new URLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
final QuasarInstrumentor instrumentor = new QuasarInstrumentor(true);
instrumentor.setCheck(check);
instrumentor.setVerbose(verbose);
instrumentor.setDebug(debug);
instrumentor.setAllowMonitors(allowMonitors);
instrumentor.setAllowBlocking(allowBlocking);
instrumentor.setLog(new Log() {
@Override
public void log(LogLevel level, String msg, Object... args) {
final int msgLevel;
switch(level) {
case DEBUG:
msgLevel = Project.MSG_DEBUG;
break;
case INFO:
msgLevel = Project.MSG_INFO;
break;
case WARNING:
msgLevel = Project.MSG_WARN;
break;
default:
throw new AssertionError("Unhandled log level: " + level);
}
InstrumentationTask.this.log(level + ": " + String.format(msg, args), msgLevel);
}
@Override
public void error(String msg, Throwable ex) {
InstrumentationTask.this.log("ERROR: " + msg, ex, Project.MSG_ERR);
}
});
for (FileSet fs : filesets) {
final DirectoryScanner ds = fs.getDirectoryScanner(getProject());
final String[] includedFiles = ds.getIncludedFiles();
for (String filename : includedFiles) {
if (filename.endsWith(".class")) {
File file = new File(fs.getDir(), filename);
if (file.isFile()) {
final String className = instrumentor.checkClass(cl, file);
workList.add(new WorkListEntry(className, file));
} else
log("File not found: " + filename);
}
}
}
instrumentor.log(LogLevel.INFO, "Instrumenting " + workList.size() + " classes");
for (WorkListEntry f : workList) instrumentClass(cl, instrumentor, f);
} catch (Exception ex) {
log(ex.getMessage());
throw new BuildException(ex.getMessage(), ex);
}
}
use of org.apache.tools.ant.DirectoryScanner in project quasar by puniverse.
the class OldSuspendablesScanner method execute.
@Override
public void execute() throws BuildException {
readSuspandables();
if (USE_REFLECTION)
log("Using reflection", Project.MSG_INFO);
try {
List<URL> urls = new ArrayList<>();
for (FileSet fs : filesets) urls.add(fs.getDir().toURI().toURL());
cl = new URLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
log("URLs: " + Arrays.toString(cl.getURLs()), Project.MSG_INFO);
// scan classes in filesets
for (FileSet fs : filesets) {
try {
final DirectoryScanner ds = fs.getDirectoryScanner(getProject());
final String[] includedFiles = ds.getIncludedFiles();
for (String filename : includedFiles) {
if (filename.endsWith(CLASSFILE_SUFFIX)) {
File file = new File(fs.getDir(), filename);
if (file.isFile())
scanClass(file);
else
log("File not found: " + filename);
}
}
} catch (BuildException ex) {
log(ex.getMessage(), ex, Project.MSG_WARN);
}
}
scanSuspendablesFile();
log("OUTPUT: " + supersFile, Project.MSG_INFO);
outputResults(supersFile, append, results);
} catch (Exception e) {
log(e, Project.MSG_ERR);
throw new BuildException(e);
}
}
use of org.apache.tools.ant.DirectoryScanner in project processing by processing.
the class AppBundlerTask method copyClassPathEntries.
private void copyClassPathEntries(File javaDirectory) throws IOException {
for (FileSet fileSet : classPath) {
File classPathDirectory = fileSet.getDir();
DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
String[] includedFiles = directoryScanner.getIncludedFiles();
for (String includedFile : includedFiles) {
File source = new File(classPathDirectory, includedFile);
File destination = new File(javaDirectory, new File(includedFile).getName());
copy(source, destination);
}
}
}
Aggregations