Author: antoine
Date: Mon Feb 18 16:13:11 2013
New Revision: 1447370
URL: http://svn.apache.org/r1447370
Log:
add suppresssystemout attribute to optionally make sshexec silent PR 52070
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/manual/Tasks/sshexec.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1447370&r1=1447369&r2=1447370&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Mon Feb 18 16:13:11 2013
@@ -143,6 +143,7 @@ Ignacio Coloma
Ingenonsya France
Ingmar Stein
Irene Rusman
+Isaac Shabtay
Ivan Ivanov
J Bleijenbergh
Jack J. Woehr
@@ -335,6 +336,7 @@ Steve Loughran
Steve Morin
Steve Wadsworth
Steven E. Newton
+Sudheer Chigurupati
Takashi Okamoto
TAMURA Kent
Taoufik Romdhane
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1447370&r1=1447369&r2=1447370&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Feb 18 16:13:11 2013
@@ -117,6 +117,9 @@ Other changes:
* Add the possibility to register a custom command line argument processor.
See org.apache.tools.ant.ArgumentProcessor and manual/argumentprocessor.html
+ * add the possibility to suppress stdout in the sshexec task.
+ Bugzilla Report 50270.
+
Changes from Ant 1.8.3 TO Ant 1.8.4
===================================
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1447370&r1=1447369&r2=1447370&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Mon Feb 18 16:13:11 2013
@@ -597,6 +597,10 @@
<last>Rusman</last>
</name>
<name>
+ <first>Isaac</first>
+ <last>Shabtay</last>
+ </name>
+ <name>
<first>Ivan</first>
<last>Ivanov</last>
</name>
@@ -1348,6 +1352,10 @@
<last>Newton</last>
</name>
<name>
+ <first>Sudheer</first>
+ <last>Chigurupati</last>
+ </name>
+ <name>
<first>Takashi</first>
<last>Okamoto</last>
</name>
Modified: ant/core/trunk/manual/Tasks/sshexec.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/sshexec.html?rev=1447370&r1=1447369&r2=1447370&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/sshexec.html (original)
+++ ant/core/trunk/manual/Tasks/sshexec.html Mon Feb 18 16:13:11 2013
@@ -116,6 +116,12 @@ and won't work with versions of jsch ear
<td valign="top" align="center">No, defaults to an empty string.</td>
</tr>
<tr>
+ <td valign="top">suppresssystemout</td>
+ <td valign="top">Whether to suppress system out.
+ <em>since Ant 1.9.0</em></td>
+ <td align="center" valign="top">No, defaults to false</td>
+ </tr>
+ <tr>
<td valign="top">output</td>
<td valign="top">Name of a file to which to write the output.</td>
<td align="center" valign="top">No</td>
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java?rev=1447370&r1=1447369&r2=1447370&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
Mon Feb 18 16:13:11 2013
@@ -27,6 +27,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.StringReader;
import org.apache.tools.ant.BuildException;
@@ -73,6 +74,11 @@ public class SSHExec extends SSHBase {
"Timeout period exceeded, connection dropped.";
/**
+ * To supress writing logs to System.out
+ */
+ private boolean suppressSystemOut = false;
+
+ /**
* Constructor for SSHExecTask.
*/
public SSHExec() {
@@ -181,11 +187,21 @@ public class SSHExec extends SSHBase {
}
/**
+ * If suppressSystemOut is <code>true</code>, output will not be sent to
System.out<br/>
+ * If suppressSystemOut is <code>false</code>, normal behavior
+ * @since Ant 1.9.0
+ */
+ public void setSuppressSystemOut(boolean suppressSystemOut)
+ {
+ this.suppressSystemOut = suppressSystemOut;
+ }
+ /**
* Execute the command on the remote host.
*
* @exception BuildException Most likely a network error or bad parameter.
*/
public void execute() throws BuildException {
+
if (getHost() == null) {
throw new BuildException("Host is required.");
}
@@ -262,9 +278,7 @@ public class SSHExec extends SSHBase {
private void executeCommand(Session session, String cmd, StringBuffer sb)
throws BuildException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- TeeOutputStream tee =
- new TeeOutputStream(out,
- KeepAliveOutputStream.wrapSystemOut());
+ OutputStream tee = suppressSystemOut ? out : new TeeOutputStream(out,
KeepAliveOutputStream.wrapSystemOut());
InputStream istream = null ;
if (inputFile != null) {
@@ -407,4 +421,5 @@ public class SSHExec extends SSHBase {
}
}
}
-}
\ No newline at end of file
+
+}