Browse Source

Make resolveExecutable method useful for subclasses

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275659 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
24f4015568
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java

+ 8
- 6
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -363,14 +363,16 @@ public class ExecTask extends Task {
* fallback to the straight executable name (i.e. on ther path) * fallback to the straight executable name (i.e. on ther path)
* *
* @return the executable as a full path if it can be determined. * @return the executable as a full path if it can be determined.
*
* @since Ant 1.6
*/ */
private String resolveExecutable() {
protected String resolveExecutable(String exec) {
if (!resolveExecutable) { if (!resolveExecutable) {
return executable;
return exec;
} }


// try to find the executable // try to find the executable
File executableFile = getProject().resolveFile(executable);
File executableFile = getProject().resolveFile(exec);
if (executableFile.exists()) { if (executableFile.exists()) {
return executableFile.getAbsolutePath(); return executableFile.getAbsolutePath();
} }
@@ -378,14 +380,14 @@ public class ExecTask extends Task {
// now try to resolve against the dir if given // now try to resolve against the dir if given
if (dir != null) { if (dir != null) {
FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
executableFile = fileUtils.resolveFile(dir, executable);
executableFile = fileUtils.resolveFile(dir, exec);
if (executableFile.exists()) { if (executableFile.exists()) {
return executableFile.getAbsolutePath(); return executableFile.getAbsolutePath();
} }
} }


// couldn't find it - must be on path // couldn't find it - must be on path
return executable;
return exec;
} }


/** /**
@@ -400,7 +402,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());
cmdl.setExecutable(resolveExecutable(executable));
checkConfiguration(); checkConfiguration();
if (isValidOs()) { if (isValidOs()) {
try { try {


Loading…
Cancel
Save