diff --git a/WHATSNEW b/WHATSNEW index 95bb5f597..cf14e9ad0 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -31,6 +31,9 @@ Fixed bugs: * The gcj compiler adapter for failed if the destination 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: -------------- * Translate task logs a debug message specifying the number of files diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index 779499546..c9db37558 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -1,7 +1,7 @@ /* * 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. * * Redistribution and use in source and binary forms, with or without @@ -476,6 +476,9 @@ public class Execute { launcher = shellLauncher; } + if (dir != null && !dir.exists()) { + throw new BuildException(dir + " doesn't exists."); + } return launcher.exec(project, command, env, dir); } @@ -487,6 +490,9 @@ public class Execute { * of the subprocess failed */ public int execute() throws IOException { + if (workingDirectory != null && !workingDirectory.exists()) { + throw new BuildException(workingDirectory + " doesn't exists."); + } final Process process = launch(project, getCommandline(), getEnvironment(), workingDirectory, useVMLauncher); @@ -536,6 +542,9 @@ public class Execute { * @since ant 1.6 */ public void spawn() throws IOException { + if (workingDirectory != null && !workingDirectory.exists()) { + throw new BuildException(workingDirectory + " doesn't exists."); + } final Process process = launch(project, getCommandline(), getEnvironment(), workingDirectory, useVMLauncher); @@ -625,7 +634,7 @@ public class Execute { // so we only return the new values which then will be set in // the generated DCL script, inheriting the parent process environment if (Os.isFamily("openvms")) { - return env; + return env; } Vector osEnv = (Vector) getProcEnvironment().clone();