Browse Source

Add special local/remote variants of the file and todir attributes to

explicitly state what is local or remote.

Document verbose attribute.

Submitted by:	Rami Ojares


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276297 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
83b7e75aa8
2 changed files with 88 additions and 8 deletions
  1. +45
    -3
      docs/manual/OptionalTasks/scp.html
  2. +43
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java

+ 45
- 3
docs/manual/OptionalTasks/scp.html View File

@@ -20,7 +20,7 @@ remote machine.</p>
in the Ant distribution. See <a
href="../install.html#librarydependencies">Library Dependencies</a>
for more information. This task has been tested with jsch-0.1.2 to
jsch-0.1.9.</p>
jsch-0.1.14.</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -34,18 +34,53 @@ jsch-0.1.9.</p>
<td valign="top">The file to copy. This can be a local path or a
remote path of the form <i>user[:password]@host:/directory/path</i>.
<i>:password</i> can be ommitted if you use key based
authentication or specify the password attribute.</td>
authentication or specify the password attribute. The way remote
path is recognized is whether it contains @ character or not. This
will not work if your localPath contains @ character.</td>
<td valign="top" align="center">Yes, unless a nested
<code>&lt;fileset&gt;</code> element is used.</td>
</tr>
<tr>
<td valign="top">localFile</td>
<td valign="top">This is an alternative to the file attribute. But
this must always point to a local file. The reason this was added
was that when you give file attribute it is treated as remote if
it contains @ character. This character can exist also in local
paths. <em>since Ant 1.6.2</em></td>
<td valign="top" align="center">Alternative to file attribute.</td>
</tr>
<tr>
<td valign="top">remoteFile</td>
<td valign="top">This is an alternative to the file attribute. But
this must always point to a remote file. <em>since Ant 1.6.2</em></td>
<td valign="top" align="center">Alternative to file attribute.</td>
</tr>
<tr>
<td valign="top">todir</td>
<td valign="top">The directory to copy to. This can be a local path
or a remote path of the form <i>user[:password]@host:/directory/path</i>.
<i>:password</i> can be ommitted if you use key based
authentication or specify the password attribute.</td>
authentication or specify the password attribute. The way remote
path is recognized is whether it contains @ character or not. This
will not work if your localPath contains @ character.</td>
<td valian="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">localTodir</td>
<td valign="top">This is an alternative to the todir
attribute. But this must always point to a local directory. The
reason this was added was that when you give todir attribute it is
treated as remote if it contains @ character. This character can
exist also in local paths. <em>since Ant 1.6.2</em></td>
<td valian="top" align="center">Alternative to todir attribute.</td>
</tr>
<tr>
<td valign="top">remoteTodir</td>
<td valign="top">This is an alternative to the todir
attribute. But this must always point to a remote directory.
<em>since Ant 1.6.2</em></td>
<td valian="top" align="center">Alternative to todir attribute.</td>
</tr>
<tr>
<td valign="top">port</td>
<td valign="top">The port to connect to on the remote host.</td>
@@ -92,6 +127,13 @@ jsch-0.1.9.</p>
<td valign="top" align="center">Yes, if you are using key based
authentication.</td>
</tr>
<tr>
<td valign="top">verbose</td>
<td valign="top">Determines whether SCP outputs verbosely to the
user. Currently this means outputting dots/stars showing the
progress of a file transfer. <em>since Ant 1.6.2</em></td>
<td valign="top" align="center">No; defaults to false.</td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>



+ 43
- 5
src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java View File

@@ -43,6 +43,7 @@ public class Scp extends SSHBase {
private String fromUri;
private String toUri;
private List fileSets = null;
private boolean isFromRemote, isToRemote;

/**
* Sets the file to be transferred. This can either be a remote
@@ -55,6 +56,7 @@ public class Scp extends SSHBase {
*/
public void setFile(String aFromUri) {
this.fromUri = aFromUri;
this.isFromRemote = isRemoteUri(this.fromUri);
}

/**
@@ -68,9 +70,50 @@ public class Scp extends SSHBase {
*/
public void setTodir(String aToUri) {
this.toUri = aToUri;
this.isToRemote = isRemoteUri(this.toUri);
}

/**
* Similiar to {@link #setFile setFile} but explicitly states that
* the file is a local file. This is the only way to specify a
* local file with a @ character.
* @since Ant 1.6.2
*/
public void setLocalFile(String aFromUri) {
this.fromUri = aFromUri;
this.isFromRemote = false;
}

/**
* Similiar to {@link #setFile setFile} but explicitly states that
* the file is a remote file.
* @since Ant 1.6.2
*/
public void setRemoteFile(String aFromUri) {
this.fromUri = aFromUri;
this.isFromRemote = true;
}

/**
* Similiar to {@link #setTodir setTodir} but explicitly states
* that the directory is a local. This is the only way to specify
* a local directory with a @ character.
* @since Ant 1.6.2
*/
public void setLocalTodir(String aToUri) {
this.toUri = aToUri;
this.isToRemote = false;
}

/**
* Similiar to {@link #setTodir setTodir} but explicitly states
* that the directory is a remote.
* @since Ant 1.6.2
*/
public void setRemoteTodir(String aToUri) {
this.toUri = aToUri;
this.isToRemote = true;
}

/**
* Adds a FileSet tranfer to remote host. NOTE: Either
@@ -102,11 +145,6 @@ public class Scp extends SSHBase {
+ "FileSet is required.");
}

boolean isFromRemote = false;
if (fromUri != null) {
isFromRemote = isRemoteUri(fromUri);
}
boolean isToRemote = isRemoteUri(toUri);
try {
if (isFromRemote && !isToRemote) {
download(fromUri, toUri);


Loading…
Cancel
Save