Browse Source

Fail with a useful error message when the user asks us to fork a

process in a directory that doesn't exist.

PR: 25455


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275988 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
6c29f89924
2 changed files with 14 additions and 2 deletions
  1. +3
    -0
      WHATSNEW
  2. +11
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java

+ 3
- 0
WHATSNEW View File

@@ -31,6 +31,9 @@ Fixed bugs:
* The gcj compiler adapter for <javac> failed if the destination * The gcj compiler adapter for <javac> failed if the destination
directory didn't exist. Bugzilla Report 25856. directory didn't exist. Bugzilla Report 25856.


* Ant now fails with a more useful message if a new process will be
forked in a directory and that directory doesn't exist.

Other changes: Other changes:
-------------- --------------
* Translate task logs a debug message specifying the number of files * Translate task logs a debug message specifying the number of files


+ 11
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -476,6 +476,9 @@ public class Execute {
launcher = shellLauncher; launcher = shellLauncher;
} }


if (dir != null && !dir.exists()) {
throw new BuildException(dir + " doesn't exists.");
}
return launcher.exec(project, command, env, dir); return launcher.exec(project, command, env, dir);
} }


@@ -487,6 +490,9 @@ public class Execute {
* of the subprocess failed * of the subprocess failed
*/ */
public int execute() throws IOException { public int execute() throws IOException {
if (workingDirectory != null && !workingDirectory.exists()) {
throw new BuildException(workingDirectory + " doesn't exists.");
}
final Process process = launch(project, getCommandline(), final Process process = launch(project, getCommandline(),
getEnvironment(), workingDirectory, getEnvironment(), workingDirectory,
useVMLauncher); useVMLauncher);
@@ -536,6 +542,9 @@ public class Execute {
* @since ant 1.6 * @since ant 1.6
*/ */
public void spawn() throws IOException { public void spawn() throws IOException {
if (workingDirectory != null && !workingDirectory.exists()) {
throw new BuildException(workingDirectory + " doesn't exists.");
}
final Process process = launch(project, getCommandline(), final Process process = launch(project, getCommandline(),
getEnvironment(), workingDirectory, getEnvironment(), workingDirectory,
useVMLauncher); useVMLauncher);
@@ -625,7 +634,7 @@ public class Execute {
// so we only return the new values which then will be set in // so we only return the new values which then will be set in
// the generated DCL script, inheriting the parent process environment // the generated DCL script, inheriting the parent process environment
if (Os.isFamily("openvms")) { if (Os.isFamily("openvms")) {
return env;
return env;
} }


Vector osEnv = (Vector) getProcEnvironment().clone(); Vector osEnv = (Vector) getProcEnvironment().clone();


Loading…
Cancel
Save