use of org.apache.tools.ant.types.FileSet in project ant by apache.
the class FTP method transferFiles.
/**
* Sends all files specified by the configured filesets to the remote
* server.
*
* @param ftp the FTPClient instance used to perform FTP actions
*
* @throws IOException if there is a problem reading a file
* @throws BuildException if there is a problem in the configuration.
*/
protected void transferFiles(FTPClient ftp) throws IOException, BuildException {
transferred = 0;
skipped = 0;
if (filesets.isEmpty()) {
throw new BuildException("at least one fileset must be specified.");
}
for (FileSet fs : filesets) {
if (fs != null) {
transferFiles(ftp, fs);
}
}
log(transferred + " " + ACTION_TARGET_STRS[action] + " " + COMPLETED_ACTION_STRS[action]);
if (skipped != 0) {
log(skipped + " " + ACTION_TARGET_STRS[action] + " were not successfully " + COMPLETED_ACTION_STRS[action]);
}
}
use of org.apache.tools.ant.types.FileSet in project ant by apache.
the class FTPTaskMirrorImpl method transferFiles.
/**
* Sends all files specified by the configured filesets to the remote
* server.
*
* @param ftp the FTPClient instance used to perform FTP actions
*
* @throws IOException if there is a problem reading a file
* @throws BuildException if there is a problem in the configuration.
*/
protected void transferFiles(FTPClient ftp) throws IOException, BuildException {
transferred = 0;
skipped = 0;
if (task.getFilesets().isEmpty()) {
throw new BuildException("at least one fileset must be specified.");
}
// get files from filesets
for (FileSet fs : task.getFilesets()) {
if (fs != null) {
transferFiles(ftp, fs);
}
}
task.log(transferred + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()] + " " + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
if (skipped != 0) {
task.log(skipped + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()] + " were not successfully " + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
}
}
use of org.apache.tools.ant.types.FileSet in project ant by apache.
the class Scp method upload.
private void upload(final List<ResourceCollection> rcs, final String toSshUri) throws IOException, JSchException {
final String file = parseUri(toSshUri);
Session session = null;
try {
final List<Directory> list = new ArrayList<>(rcs.size());
for (ResourceCollection rc : rcs) {
if (rc instanceof FileSet && rc.isFilesystemOnly()) {
FileSet fs = (FileSet) rc;
final Directory d = createDirectory(fs);
if (d != null) {
list.add(d);
}
} else {
List<Directory> ds = createDirectoryCollection(rc);
if (ds != null) {
list.addAll(ds);
}
}
}
if (!list.isEmpty()) {
session = openSession();
ScpToMessage message;
if (!isSftp) {
message = new ScpToMessage(getVerbose(), compressed, session, list, file, preserveLastModified);
} else {
message = new ScpToMessageBySftp(getVerbose(), session, list, file, preserveLastModified);
}
message.setLogListener(this);
if (fileMode != null) {
message.setFileMode(fileMode);
}
if (dirMode != null) {
message.setDirMode(dirMode);
}
message.execute();
}
} finally {
if (session != null) {
session.disconnect();
}
}
}
use of org.apache.tools.ant.types.FileSet in project ant by apache.
the class AbstractAccessTask method setFile.
/**
* Set the file which should have its access attributes modified.
* @param src the file to modify
*/
public void setFile(File src) {
FileSet fs = new FileSet();
fs.setFile(src);
addFileset(fs);
}
use of org.apache.tools.ant.types.FileSet in project ant by apache.
the class Symlink method loadLinks.
/**
* Load links from properties files included in one or more FileSets.
*
* <p>This method is only invoked when the action attribute is set to
* "recreate". The filesets passed in are assumed to specify the
* names of the property files with the link information and the
* subdirectories in which to look for them.</p>
*
* @param fileSets The <code>FileSet</code>s for this task.
* @return The links to be made.
*/
private Properties loadLinks(List<FileSet> fileSets) {
Properties finalList = new Properties();
// loop through the supplied file sets:
for (FileSet fs : fileSets) {
DirectoryScanner ds = new DirectoryScanner();
fs.setupDirectoryScanner(ds, getProject());
ds.setFollowSymlinks(false);
ds.scan();
File dir = fs.getDir(getProject());
// load included files as properties files:
for (String name : ds.getIncludedFiles()) {
File inc = new File(dir, name);
File pf = inc.getParentFile();
Properties lnks = new Properties();
try (InputStream is = new BufferedInputStream(Files.newInputStream(inc.toPath()))) {
lnks.load(is);
pf = pf.getCanonicalFile();
} catch (FileNotFoundException fnfe) {
handleError("Unable to find " + name + "; skipping it.");
continue;
} catch (IOException ioe) {
handleError("Unable to open " + name + " or its parent dir; skipping it.");
continue;
}
try {
lnks.store(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)), "listing properties");
} catch (IOException ex) {
log("failed to log unshortened properties");
lnks.list(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
}
// working directory:
for (String key : lnks.stringPropertyNames()) {
finalList.put(new File(pf, key).getAbsolutePath(), lnks.getProperty(key));
}
}
}
return finalList;
}
Aggregations