Browse Source

Added searchpath attribute to <exec> for searching path

variables when resolveexecutable = true.  Thanks to Stefan
for having already written the path-searching code.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276847 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
1e6b276526
3 changed files with 26 additions and 3 deletions
  1. +3
    -0
      WHATSNEW
  2. +10
    -2
      docs/manual/CoreTasks/exec.html
  3. +13
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java

+ 3
- 0
WHATSNEW View File

@@ -50,6 +50,9 @@ Other changes:
* It is now possible to specify the pattern created/parsed by <checksum>. * It is now possible to specify the pattern created/parsed by <checksum>.
Bugzilla Report 16539. Bugzilla Report 16539.


* Added searchpath attribute to <exec> for searching path variable(s)
when resolveexecutable = true.

Changes from Ant 1.6.2 to current Ant 1.6 CVS version Changes from Ant 1.6.2 to current Ant 1.6 CVS version
===================================================== =====================================================




+ 10
- 2
docs/manual/CoreTasks/exec.html View File

@@ -212,15 +212,23 @@ or the task will fail as follows:
<td align="center" valign="top">No, default is <i>true</i></td> <td align="center" valign="top">No, default is <i>true</i></td>
</tr> </tr>
<tr> <tr>
<td valign="top">resolveExecutable</td>
<td valign="top">resolveexecutable</td>
<td valign="top">When this attribute is true, the name of the executable <td valign="top">When this attribute is true, the name of the executable
if resolved firstly against the project basedir and
is resolved firstly against the project basedir and
if that does not exist, against the execution if that does not exist, against the execution
directory if specified. On Unix systems, if you only directory if specified. On Unix systems, if you only
want to allow execution of commands in the user's path, want to allow execution of commands in the user's path,
set this to false. <em>since Ant 1.6</em></td> set this to false. <em>since Ant 1.6</em></td>
<td align="center" valign="top">No, default is <i>false</i></td> <td align="center" valign="top">No, default is <i>false</i></td>
</tr> </tr>
<tr>
<td valign="top">searchpath</td>
<td valign="top">When this attribute is true nested, then
system path environment variables will
be searched when resolving the location
of the executable. <em>since Ant 1.6.3</em></td>
<td align="center" valign="top">No, default is <i>false</i></td>
</tr>
</table> </table>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>


+ 13
- 1
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -51,6 +51,7 @@ public class ExecTask extends Task {
private boolean failIfExecFails = true; private boolean failIfExecFails = true;
private String executable; private String executable;
private boolean resolveExecutable = false; private boolean resolveExecutable = false;
private boolean searchPath = false;
private boolean spawn = false; private boolean spawn = false;
private boolean incompatibleWithSpawn = false; private boolean incompatibleWithSpawn = false;


@@ -260,6 +261,16 @@ public class ExecTask extends Task {
this.resolveExecutable = resolveExecutable; this.resolveExecutable = resolveExecutable;
} }


/**
* Sets a flag indicating whether to search nested, then
* system PATH environment variables for the executable.
*
* @param searchPath if true, search PATHs
*/
public void setSearchPath(boolean searchPath) {
this.searchPath = searchPath;
}

/** /**
* Indicates whether to attempt to resolve the executable to a * Indicates whether to attempt to resolve the executable to a
* file * file
@@ -345,6 +356,7 @@ public class ExecTask extends Task {
* Add a <CODE>RedirectorElement</CODE> to this task. * Add a <CODE>RedirectorElement</CODE> to this task.
* *
* @param redirectorElement <CODE>RedirectorElement</CODE>. * @param redirectorElement <CODE>RedirectorElement</CODE>.
* @since Ant 1.6.2
*/ */
public void addConfiguredRedirector(RedirectorElement redirectorElement) { public void addConfiguredRedirector(RedirectorElement redirectorElement) {
if (this.redirectorElement != null) { if (this.redirectorElement != null) {
@@ -444,7 +456,7 @@ public class ExecTask extends Task {
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
File savedDir = dir; // possibly altered in prepareExec File savedDir = dir; // possibly altered in prepareExec
cmdl.setExecutable(resolveExecutable(executable, false));
cmdl.setExecutable(resolveExecutable(executable, searchPath));
checkConfiguration(); checkConfiguration();
if (isValidOs()) { if (isValidOs()) {
try { try {


Loading…
Cancel
Save