diff --git a/WHATSNEW b/WHATSNEW index 276d5f89a..0e864e2c4 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -50,6 +50,9 @@ Other changes: * It is now possible to specify the pattern created/parsed by . Bugzilla Report 16539. +* Added searchpath attribute to for searching path variable(s) + when resolveexecutable = true. + Changes from Ant 1.6.2 to current Ant 1.6 CVS version ===================================================== diff --git a/docs/manual/CoreTasks/exec.html b/docs/manual/CoreTasks/exec.html index c331e1330..1a5da5d70 100644 --- a/docs/manual/CoreTasks/exec.html +++ b/docs/manual/CoreTasks/exec.html @@ -212,15 +212,23 @@ or the task will fail as follows: No, default is true - resolveExecutable + resolveexecutable 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 directory if specified. On Unix systems, if you only want to allow execution of commands in the user's path, set this to false. since Ant 1.6 No, default is false + + searchpath + When this attribute is true nested, then + system path environment variables will + be searched when resolving the location + of the executable. since Ant 1.6.3 + No, default is false +

Examples

diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index 9205e553d..963cbb8de 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -51,6 +51,7 @@ public class ExecTask extends Task { private boolean failIfExecFails = true; private String executable; private boolean resolveExecutable = false; + private boolean searchPath = false; private boolean spawn = false; private boolean incompatibleWithSpawn = false; @@ -260,6 +261,16 @@ public class ExecTask extends Task { 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 * file @@ -345,6 +356,7 @@ public class ExecTask extends Task { * Add a RedirectorElement to this task. * * @param redirectorElement RedirectorElement. + * @since Ant 1.6.2 */ public void addConfiguredRedirector(RedirectorElement redirectorElement) { if (this.redirectorElement != null) { @@ -444,7 +456,7 @@ public class ExecTask extends Task { */ public void execute() throws BuildException { File savedDir = dir; // possibly altered in prepareExec - cmdl.setExecutable(resolveExecutable(executable, false)); + cmdl.setExecutable(resolveExecutable(executable, searchPath)); checkConfiguration(); if (isValidOs()) { try {