use of org.apache.tools.ant.types.FileSet in project openj9 by eclipse.
the class ExecOverFiles method execute.
public void execute() throws BuildException {
if (exec == null) {
throw new BuildException("No <exec> nested element supplied.");
}
if (command == null || command.length() == 0) {
throw new BuildException("No non-empty command attribute supplied.");
}
for (FileSet fs : fileSets) {
DirectoryScanner scanner = fs.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
exec.setDir(scanner.getBasedir());
for (String filename : files) {
Commandline cmd = new Commandline(command.replace(FILENAME_REPLACE, filename));
exec.setCommand(cmd);
// overwrites file with output
exec.setOutput(new File(scanner.getBasedir() + "/" + filename));
exec.execute();
}
}
}
use of org.apache.tools.ant.types.FileSet in project tomcat70 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.
Iterator<FileSet> iter = filesets.iterator();
while (iter.hasNext()) {
FileSet fs = iter.next();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File basedir = ds.getBasedir();
String[] files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File from = new File(basedir, files[i]);
File to = new File(todir, files[i] + ".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 maven-plugins by apache.
the class DependencyFilesetsTask method execute.
/**
* {@inheritDoc}
*/
public void execute() {
if (this.getProject().getReference(mavenProjectId) == null) {
throw new BuildException("Maven project reference not found: " + mavenProjectId);
}
MavenProject mavenProject = (MavenProject) this.getProject().getReference("maven.project");
// Add filesets for depenedency artifacts
Set<Artifact> depArtifacts = filterArtifacts(mavenProject.getArtifacts());
FileSet dependenciesFileSet = new FileSet();
dependenciesFileSet.setProject(getProject());
ArtifactRepository localRepository = (ArtifactRepository) getProject().getReference("maven.local.repository");
dependenciesFileSet.setDir(new File(localRepository.getBasedir()));
if (depArtifacts.isEmpty()) {
// For performance reasons in case of huge local repo, tell Ant to include a single thing, otherwise the
// whole directory is scanned (even though ** is excluded).
dependenciesFileSet.createInclude().setName(".");
dependenciesFileSet.createExclude().setName("**");
}
for (Artifact artifact : depArtifacts) {
String relativeArtifactPath = localRepository.pathOf(artifact);
dependenciesFileSet.createInclude().setName(relativeArtifactPath);
String fileSetName = getPrefix() + artifact.getDependencyConflictId();
FileSet singleArtifactFileSet = new FileSet();
singleArtifactFileSet.setProject(getProject());
singleArtifactFileSet.setFile(artifact.getFile());
getProject().addReference(fileSetName, singleArtifactFileSet);
}
getProject().addReference((getPrefix() + projectDependenciesId), dependenciesFileSet);
}
use of org.apache.tools.ant.types.FileSet in project groovy-core by groovy.
the class FileIterator method setNextObject.
// Implementation methods
// -------------------------------------------------------------------------
/*
* Set nextObject to the next object. If there are no more
* objects then return false. Otherwise, return true.
*/
private boolean setNextObject() {
while (true) {
while (ds == null) {
if (!fileSetIterator.hasNext()) {
return false;
}
FileSet fs = fileSetIterator.next();
ds = fs.getDirectoryScanner(project);
ds.scan();
if (iterateDirectories) {
files = ds.getIncludedDirectories();
} else {
files = ds.getIncludedFiles();
}
if (files.length > 0) {
fileIndex = -1;
break;
} else {
ds = null;
}
}
if (ds != null && files != null) {
if (++fileIndex < files.length) {
nextFile = new File(ds.getBasedir(), files[fileIndex]);
nextObjectSet = true;
return true;
} else {
ds = null;
}
}
}
}
use of org.apache.tools.ant.types.FileSet in project randomizedtesting by randomizedtesting.
the class MergeHints method add.
/**
* Adds a resource collection with execution hints.
*/
public void add(ResourceCollection rc) {
if (rc instanceof FileSet) {
FileSet fs = (FileSet) rc;
fs.setProject(getProject());
}
resources.add(rc);
}
Aggregations