diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3e2ce0254..188e1c2d6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -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 diff --git a/WHATSNEW b/WHATSNEW index 1b002caff..f548d2f6b 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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 =================================== diff --git a/contributors.xml b/contributors.xml index 543e200f7..9471800e0 100644 --- a/contributors.xml +++ b/contributors.xml @@ -596,6 +596,10 @@ Irene Rusman + + Isaac + Shabtay + Ivan Ivanov @@ -1347,6 +1351,10 @@ E. Newton + + Sudheer + Chigurupati + Takashi Okamoto diff --git a/manual/Tasks/sshexec.html b/manual/Tasks/sshexec.html index 38e5b35e3..0c130e812 100644 --- a/manual/Tasks/sshexec.html +++ b/manual/Tasks/sshexec.html @@ -115,6 +115,12 @@ and won't work with versions of jsch earlier than Passphrase for your private key. No, defaults to an empty string. + + suppresssystemout + Whether to suppress system out. + since Ant 1.9.0 + No, defaults to false + output Name of a file to which to write the output. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java index 2258d515e..113565101 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java @@ -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; @@ -72,6 +73,11 @@ public class SSHExec extends SSHBase { private static final String TIMEOUT_MESSAGE = "Timeout period exceeded, connection dropped."; + /** + * To supress writing logs to System.out + */ + private boolean suppressSystemOut = false; + /** * Constructor for SSHExecTask. */ @@ -180,12 +186,22 @@ public class SSHExec extends SSHBase { usePty = b; } + /** + * If suppressSystemOut is true, output will not be sent to System.out
+ * If suppressSystemOut is false, 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 + +}