ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Haas <>
Subject Re: How to make the build fail when exec encounters non-zero exit code?
Date Tue, 04 Apr 2000 06:39:14 GMT
Hi Kevin

Hack the Java/Exec task. I am having the same problem and addedsome code to
Change the execute method to

    public void execute() throws BuildException {
        if (run(command) != 0) {
            throw new BuildException("Exec failed.");

I do not feel ready to contribute this patch, because I feel Java/Exec
should be improved beyond exit on errors:

  1. Use String[] as commandline instead of a String, as the String gets
     parsed Runtime.exec and it would be easier to specify arguments
     containing spaces.
  2. Get rid of antRun on Unix - is there a real need for this?
  3. Move the functionality from Exec to a seperate class to allow tasks not
     inheriting from Exec to spawn processes (like Javadoc and Jikes).
  4. Many more feature like tunable output and a watchdog to kill hanging

(I am working on some of the above)

- tom

Kevin Riff wrote:

> I have a build.xml file which uses the Java task with fork="yes" to
> execute JavaCC in an external process. It works great except that if
> there's a problem with the grammar files, then Ant reports the exit code
> (1, I think) but continues to process the next target. How can I cause
> Ant to stop the build process immediately when it encounters a non-zero
> exit code?

* Thomas Haas                    <>
* SoftWired AG                   <>
* Technoparkstr. 1  ***  CH-8005 Zurich  ***  +41-1-4452370

View raw message