use of org.apache.tools.ant.types.FileSet in project datanucleus-core by datanucleus.
the class EnhancerTask method getDirectoryScanner.
private DirectoryScanner getDirectoryScanner(File dir) {
FileSet fileset = new FileSet();
fileset.setDir(dir);
return fileset.getDirectoryScanner(getProject());
}
use of org.apache.tools.ant.types.FileSet in project datanucleus-core by datanucleus.
the class SchemaToolTask method getFiles.
protected File[] getFiles() {
List<File> v = new ArrayList<File>();
Iterator<FileSet> filesetIter = filesets.iterator();
while (filesetIter.hasNext()) {
FileSet fs = filesetIter.next();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
ds.scan();
String[] f = ds.getIncludedFiles();
for (int j = 0; j < f.length; j++) {
String pathname = f[j];
File file = new File(ds.getBasedir(), pathname);
file = getProject().resolveFile(file.getPath());
v.add(file);
}
}
return v.toArray(new File[v.size()]);
}
use of org.apache.tools.ant.types.FileSet in project camunda-bpm-platform by camunda.
the class DeployBarTask method execute.
public void execute() throws BuildException {
List<File> files = new ArrayList<File>();
if (file != null) {
files.add(file);
}
if (fileSets != null) {
for (FileSet fileSet : fileSets) {
DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
File baseDir = directoryScanner.getBasedir();
String[] includedFiles = directoryScanner.getIncludedFiles();
String[] excludedFiles = directoryScanner.getExcludedFiles();
List<String> excludedFilesList = Arrays.asList(excludedFiles);
for (String includedFile : includedFiles) {
if (!excludedFilesList.contains(includedFile)) {
files.add(new File(baseDir, includedFile));
}
}
}
}
Thread currentThread = Thread.currentThread();
ClassLoader originalClassLoader = currentThread.getContextClassLoader();
currentThread.setContextClassLoader(DeployBarTask.class.getClassLoader());
LogUtil.readJavaUtilLoggingConfigFromClasspath();
try {
log("Initializing process engine " + processEngineName);
ProcessEngines.init();
ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName);
if (processEngine == null) {
List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
if (processEngineInfos != null && processEngineInfos.size() > 0) {
// Since no engine with the given name is found, we can't be 100% sure which ProcessEngineInfo
// is causing the error. We should show ALL errors and process engine names / resource URL's.
String message = getErrorMessage(processEngineInfos, processEngineName);
throw new ProcessEngineException(message);
} else
throw new ProcessEngineException("Could not find a process engine with name '" + processEngineName + "', no engines found. " + "Make sure an engine configuration is present on the classpath");
}
RepositoryService repositoryService = processEngine.getRepositoryService();
log("Starting to deploy " + files.size() + " files");
for (File file : files) {
String path = file.getAbsolutePath();
log("Handling file " + path);
try {
FileInputStream inputStream = new FileInputStream(file);
try {
log("deploying bar " + path);
repositoryService.createDeployment().name(file.getName()).addZipInputStream(new ZipInputStream(inputStream)).deploy();
} finally {
IoUtil.closeSilently(inputStream);
}
} catch (Exception e) {
throw new BuildException("couldn't deploy bar " + path + ": " + e.getMessage(), e);
}
}
} finally {
currentThread.setContextClassLoader(originalClassLoader);
}
}
use of org.apache.tools.ant.types.FileSet in project pmd by pmd.
the class CPDTask method tokenizeFiles.
private void tokenizeFiles(CPD cpd) throws IOException {
for (FileSet fileSet : filesets) {
DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
String[] includedFiles = directoryScanner.getIncludedFiles();
for (int i = 0; i < includedFiles.length; i++) {
File file = new File(directoryScanner.getBasedir() + System.getProperty("file.separator") + includedFiles[i]);
log("Tokenizing " + file.getAbsolutePath(), Project.MSG_VERBOSE);
cpd.add(file);
}
}
}
use of org.apache.tools.ant.types.FileSet in project openj9 by eclipse.
the class JUnitResultsSummary method execute.
@Override
public void execute() throws BuildException {
StringBuilder out = new StringBuilder();
if (fileSets.size() == 0) {
throw new BuildException("No filesets supplied.");
}
if ((property == null) && (null == file)) {
throw new BuildException("property or output file not specified");
}
int count = 0;
for (FileSet thisFileSet : fileSets) {
DirectoryScanner scanner = thisFileSet.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
if (files.length == 0) {
log("Empty fileset supplied");
}
for (String fileName : files) {
File thisFile = new File(scanner.getBasedir(), fileName);
try {
if (!thisFile.exists()) {
log("Ignoring " + thisFile.getCanonicalPath() + ", because it doesn't exist");
continue;
}
if (verbose) {
log("Processing file " + thisFile.getCanonicalPath());
}
process(thisFile, out);
count++;
} catch (Exception ex) {
throw new BuildException(ex);
}
}
}
log("Processed " + count + " test cases");
if (out.length() == 0) {
out.append("No failures detected");
}
if (property != null) {
getProject().setNewProperty(property, out.toString());
}
if (file != null) {
writeOutputFile(out);
}
}
Aggregations