Bug 61274

Summary: Fail on error with spawn=true
Product: Ant Reporter: Tomas Tulka <tomas.tulka>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Tomas Tulka 2017-07-10 12:40:30 UTC
When I start a long-running process (such as a database system) with spawn=true I would like to know if the process doesn't crash already on the beginning (for instance the database system didn't start at all due to a blocked port etc).

Ant script can wait for the process in a separate thread and report a failure.

The class org.apache.tools.ant.taskdefs.Execute could be modified like this:

line 524:

new Thread(new Runnable() {
            public void run() {
                try {

                    int returnCode = process.exitValue();

                    if (Execute.isFailure(returnCode)) {
                        if (failOnError) {
                            throw new BuildException(process + " returned: " + returnCode);
                } catch (Exception e) {
                    throw new RuntimeException(e);

Thank you very much for any oppinion!

Tomas Tulka