|
58 | 58 | import org.kohsuke.stapler.QueryParameter;
|
59 | 59 |
|
60 | 60 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 61 | +import hudson.remoting.VirtualChannel; |
61 | 62 |
|
62 | 63 | import java.io.File;
|
63 | 64 | import java.io.IOException;
|
@@ -395,22 +396,27 @@ public void buildEnvVars(EnvVars env) {
|
395 | 396 | * Gets the executable path of this Ant on the given target system.
|
396 | 397 | */
|
397 | 398 | public String getExecutable(Launcher launcher) throws IOException, InterruptedException {
|
398 |
| - return launcher.getChannel().call(new MasterToSlaveCallable<String,IOException>() { |
399 |
| - private static final long serialVersionUID = 906341330603832653L; |
400 |
| - public String call() throws IOException { |
401 |
| - File exe = getExeFile(); |
402 |
| - if(exe.exists()) |
403 |
| - return exe.getPath(); |
404 |
| - return null; |
405 |
| - } |
406 |
| - }); |
| 399 | + VirtualChannel channel = launcher.getChannel(); |
| 400 | + if (channel == null) { |
| 401 | + throw new IOException("offline?"); |
| 402 | + } |
| 403 | + return channel.call(new GetExecutable(getHome())); |
407 | 404 | }
|
408 |
| - |
409 |
| - private File getExeFile() { |
410 |
| - String execName = Functions.isWindows() ? "ant.bat" : "ant"; |
411 |
| - String home = Util.replaceMacro(getHome(), EnvVars.masterEnvVars); |
412 |
| - |
413 |
| - return new File(home,"bin/"+execName); |
| 405 | + private static class GetExecutable extends MasterToSlaveCallable<String, IOException> { |
| 406 | + private static final long serialVersionUID = 906341330603832653L; |
| 407 | + private final String rawHome; |
| 408 | + GetExecutable(String rawHome) { |
| 409 | + this.rawHome = rawHome; |
| 410 | + } |
| 411 | + @Override public String call() throws IOException { |
| 412 | + String execName = Functions.isWindows() ? "ant.bat" : "ant"; |
| 413 | + String home = Util.replaceMacro(rawHome, EnvVars.masterEnvVars); |
| 414 | + File exe = new File(home, "bin/" + execName); |
| 415 | + if (exe.exists()) { |
| 416 | + return exe.getPath(); |
| 417 | + } |
| 418 | + return null; |
| 419 | + } |
414 | 420 | }
|
415 | 421 |
|
416 | 422 | /**
|
|
0 commit comments