use of org.apache.tools.ant.types.FileSet in project ceylon-compiler by ceylon.
the class SourceModules method getModules.
// TODO filters by module name, supported backends (transitive)
public Set<Module> getModules() {
if (this.dir == null) {
this.dir = getProject().resolveFile(Constants.DEFAULT_SOURCE_DIR);
}
FileSet fs = new FileSet();
fs.setDir(this.dir);
// TODO Handle default module
fs.setIncludes("**/" + Constants.MODULE_DESCRIPTOR);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
log("<sourcemodules> found files " + Arrays.toString(files), Project.MSG_VERBOSE);
URI base = dir.toURI();
LinkedHashSet<Module> result = new LinkedHashSet<Module>();
try {
CeylonClassLoader loader = Util.getCeylonClassLoaderCachedInProject(getProject());
for (String file : files) {
URI uri = new File(this.dir, file).getParentFile().toURI();
log("<sourcemodules> file " + file + "=> uri " + uri, Project.MSG_VERBOSE);
String moduleName = base.relativize(uri).getPath().replace('/', '.');
if (moduleName.endsWith(".")) {
moduleName = moduleName.substring(0, moduleName.length() - 1);
}
log("<sourcemodules> file " + file + "=> moduleName " + moduleName, Project.MSG_VERBOSE);
Module mav = new Module();
mav.setName(moduleName);
String version;
try {
version = new ModuleDescriptorReader(loader, mav.getName(), dir).getModuleVersion();
} catch (NoSuchModuleException e) {
log("<sourcemodules> file " + file + "=> module cannot be read: " + moduleName, Project.MSG_VERBOSE);
// skip it
continue;
}
log("<sourcemodules> file " + file + "=> module " + moduleName + "/" + version, Project.MSG_VERBOSE);
mav.setVersion(version);
result.add(mav);
}
} catch (ClassLoaderSetupException x) {
log("failed to set up Ceylon classloader: could not load module set", Project.MSG_VERBOSE);
}
return result;
}
use of org.apache.tools.ant.types.FileSet in project ceylon-compiler by ceylon.
the class CeylonCompileJsAntTask method addToCompileList.
private void addToCompileList(List<File> dirs) {
for (File srcDir : dirs) {
if (srcDir.isDirectory()) {
FileSet fs = (FileSet) this.files.clone();
fs.setDir(srcDir);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
for (String fileName : files) compileList.add(new File(srcDir, fileName));
}
}
}
use of org.apache.tools.ant.types.FileSet in project tomcat by apache.
the class Txt2Html method execute.
/**
* Perform the conversion
*
* @throws BuildException if an error occurs during execution of
* this task.
*/
@Override
public void execute() throws BuildException {
int count = 0;
// Step through each file and convert.
for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File basedir = ds.getBasedir();
String[] files = ds.getIncludedFiles();
for (String file : files) {
File from = new File(basedir, file);
File to = new File(todir, file + ".html");
if (!to.exists() || (from.lastModified() > to.lastModified())) {
log("Converting file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath(), Project.MSG_VERBOSE);
try {
convert(from, to);
} catch (IOException e) {
throw new BuildException("Could not convert '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'", e);
}
count++;
}
}
if (count > 0) {
log("Converted " + count + " file" + (count > 1 ? "s" : "") + " to " + todir.getAbsolutePath());
}
}
}
use of org.apache.tools.ant.types.FileSet in project aries by apache.
the class EsaTaskTest method generateArchiveWithNewManifest.
@Test
public void generateArchiveWithNewManifest() {
File srcDir = new File("../src/test/resources");
assertTrue(srcDir.exists());
File destfile = new File("target/esa-test.esa");
if (destfile.exists()) {
destfile.delete();
}
assertFalse(destfile.exists());
EsaTask esaTask = new EsaTask();
Project testProject = new Project();
esaTask.setProject(testProject);
FileSet fileSet = new FileSet();
fileSet.setDir(srcDir);
fileSet.setIncludes("*.jar");
esaTask.addFileset(fileSet);
esaTask.setDestFile(destfile);
esaTask.setSymbolicName("esatask-test");
esaTask.setName("ESA Test Task");
esaTask.setVersion("1.0.0");
esaTask.setGenerateManifest(true);
esaTask.execute();
assertTrue(destfile.exists());
try {
ZipFile esaArchive = new ZipFile(destfile);
assertNotNull(esaArchive);
ZipEntry subsystemManifest = esaArchive.getEntry("OSGI-INF/SUBSYSTEM.MF");
assertNotNull(subsystemManifest);
} catch (IOException e) {
fail(e.getMessage());
}
}
use of org.apache.tools.ant.types.FileSet in project checkstyle by checkstyle.
the class CheckstyleAntTask method scanFileSets.
/**
* Returns the list of files (full path name) to process.
*
* @return the list of files included via the filesets.
*/
protected List<File> scanFileSets() {
final List<File> allFiles = new ArrayList<>();
for (int i = 0; i < fileSets.size(); i++) {
final FileSet fileSet = fileSets.get(i);
final DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
final List<File> scannedFiles = retrieveAllScannedFiles(scanner, i);
allFiles.addAll(scannedFiles);
}
return allFiles;
}
Aggregations