diff --git a/WHATSNEW b/WHATSNEW index 45434c71f..8b3c011c8 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -148,6 +148,9 @@ Fixed bugs: * now properly handles remote files and directories with spaces in their names. Bugzilla Report 26097. +* now has (local|remote)tofile attributes to rename files on the + fly. Bugzilla Report 26758. + Other changes: -------------- * doc fix concerning the dependencies of the ftp task diff --git a/docs/manual/OptionalTasks/scp.html b/docs/manual/OptionalTasks/scp.html index c65feb6ee..459215233 100644 --- a/docs/manual/OptionalTasks/scp.html +++ b/docs/manual/OptionalTasks/scp.html @@ -74,6 +74,13 @@ jsch-0.1.14.

exist also in local paths. since Ant 1.6.2 Alternative to todir attribute. + + localTofile + Changes the file name to the given name while + receiving it, only useful if receiving a single file. since + Ant 1.6.2 + Alternative to todir attribute. + remoteTodir This is an alternative to the todir @@ -81,6 +88,13 @@ jsch-0.1.14.

since Ant 1.6.2 Alternative to todir attribute. + + remoteTofile + Changes the file name to the given name while + sending it, only useful if sending a single file. since + Ant 1.6.2 + Alternative to todir attribute. + port The port to connect to on the remote host. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java index b8f167f9a..72da7ba4c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java @@ -115,6 +115,26 @@ public class Scp extends SSHBase { this.isToRemote = true; } + /** + * Changes the file name to the given name while receiving it, + * only useful if receiving a single file. + * @since Ant 1.6.2 + */ + public void setLocalTofile(String aToUri) { + this.toUri = aToUri; + this.isToRemote = false; + } + + /** + * Changes the file name to the given name while sending it, + * only useful if sending a single file. + * @since Ant 1.6.2 + */ + public void setRemoteTofile(String aToUri) { + this.toUri = aToUri; + this.isToRemote = true; + } + /** * Adds a FileSet tranfer to remote host. NOTE: Either * addFileSet() or setFile() are required. But, not both. @@ -137,7 +157,8 @@ public class Scp extends SSHBase { public void execute() throws BuildException { if (toUri == null) { - throw new BuildException("The 'todir' attribute is required."); + throw new BuildException("Either 'todir' or 'tofile' attribute " + + "is required."); } if (fromUri == null && fileSets == null) {