git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277913 13f79535-47bb-0310-9956-ffa450edef68master
@@ -257,6 +257,9 @@ Other changes: | |||||
* Ant generated jar files should now be detected as jar files by | * Ant generated jar files should now be detected as jar files by | ||||
Solaris. Bugzilla Report 32649. | Solaris. Bugzilla Report 32649. | ||||
* <rexec> with a single command should now work with unusal login | |||||
dialogs without special read/write pairs. Bugzilla Report 26632. | |||||
Fixed bugs: | Fixed bugs: | ||||
----------- | ----------- | ||||
@@ -17,6 +17,11 @@ it uses nested <tt><read></tt> to indicate strings to wait for, and | |||||
<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution. | <p><b>Note:</b> This task depends on external libraries not included in the Ant distribution. | ||||
See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p> | See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p> | ||||
<p>You can specify the commands you want to execute as nested elements | |||||
or via the command attribute, we recommend you use the command | |||||
attribute. If you use the command attribute, you must use the | |||||
username and password attributes as well.</p> | |||||
<h3>Parameters</h3> | <h3>Parameters</h3> | ||||
<table border="1" cellpadding="2" cellspacing="0"> | <table border="1" cellpadding="2" cellspacing="0"> | ||||
<tr> | <tr> | ||||
@@ -27,12 +32,12 @@ See <a href="../install.html#librarydependencies">Library Dependencies</a> for m | |||||
<tr> | <tr> | ||||
<td>userid</td> | <td>userid</td> | ||||
<td>the login id to use on the remote server.</td> | <td>the login id to use on the remote server.</td> | ||||
<td>Yes</td> | |||||
<td>No</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>password</td> | <td>password</td> | ||||
<td>the login password to use on the remote server.</td> | <td>the login password to use on the remote server.</td> | ||||
<td>Yes</td> | |||||
<td>No</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>server</td> | <td>server</td> | ||||
@@ -42,7 +47,7 @@ See <a href="../install.html#librarydependencies">Library Dependencies</a> for m | |||||
<tr> | <tr> | ||||
<td>command</td> | <td>command</td> | ||||
<td>the command to execute on the remote server.</td> | <td>the command to execute on the remote server.</td> | ||||
<td>Yes</td> | |||||
<td>No</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>port</td> | <td>port</td> | ||||
@@ -350,23 +350,20 @@ public class RExecTask extends Task { | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new BuildException("Can't connect to " + server); | throw new BuildException("Can't connect to " + server); | ||||
} | } | ||||
/** Login if userid and password were specified */ | |||||
if (userid != null && password != null) { | |||||
login(rexec); | |||||
} | |||||
/** Process each sub command */ | |||||
Enumeration tasksToRun = rexecTasks.elements(); | |||||
while (tasksToRun != null && tasksToRun.hasMoreElements()) { | |||||
RExecSubTask task = (RExecSubTask) tasksToRun.nextElement(); | |||||
if (task instanceof RExecRead && defaultTimeout != null) { | |||||
((RExecRead) task).setDefaultTimeout(defaultTimeout); | |||||
} | |||||
task.execute(rexec); | |||||
if (userid != null && password != null && command != null | |||||
&& rexecTasks.size() == 0) { | |||||
// simple one-shot execution | |||||
rexec.rexec(userid, password, command); | |||||
} else { | |||||
// need nested read/write elements | |||||
handleMultipleTasks(rexec); | |||||
} | } | ||||
/** Keep reading input stream until end of it or time-out */ | /** Keep reading input stream until end of it or time-out */ | ||||
rexec.waitForEOF(defaultTimeout); | rexec.waitForEOF(defaultTimeout); | ||||
} finally { | |||||
} catch (IOException e) { | |||||
throw new BuildException("Error r-executing command", e); | |||||
} finally { | |||||
if (rexec != null && rexec.isConnected()) { | if (rexec != null && rexec.isConnected()) { | ||||
try { | try { | ||||
rexec.disconnect(); | rexec.disconnect(); | ||||
@@ -446,4 +443,26 @@ public class RExecTask extends Task { | |||||
public void setUserid(String u) { | public void setUserid(String u) { | ||||
this.userid = u; | this.userid = u; | ||||
} | } | ||||
/** | |||||
* Deals with multiple read/write calls. | |||||
* | |||||
* @since Ant 1.6.3 | |||||
*/ | |||||
private void handleMultipleTasks(AntRExecClient rexec) { | |||||
/** Login if userid and password were specified */ | |||||
if (userid != null && password != null) { | |||||
login(rexec); | |||||
} | |||||
/** Process each sub command */ | |||||
Enumeration tasksToRun = rexecTasks.elements(); | |||||
while (tasksToRun != null && tasksToRun.hasMoreElements()) { | |||||
RExecSubTask task = (RExecSubTask) tasksToRun.nextElement(); | |||||
if (task instanceof RExecRead && defaultTimeout != null) { | |||||
((RExecRead) task).setDefaultTimeout(defaultTimeout); | |||||
} | |||||
task.execute(rexec); | |||||
} | |||||
} | |||||
} | } |