Search code examples
groovyantbuilder

Groovy AntBuilder Execute task in Background


Could use your help:

Trying to execute an ant task in Groovy so that it doesn't wait for the response from the script (i.e. run in background)

I've tried the following two ways with no success

//Cannot find script
ant.exec(failonerror: "true", executable: "scriptname.sh &") 

// Says: You have used an attribute or nested element which is not compatible with spawn 
ant.exec(failonerror: "true", spawn:"true", executable: "scriptname.sh") 

Any advice on how to accomplish this? I've searched google but can't find any good examples for Groovy.

Thanks guys, I appreciate the help.


Solution

  • Instead of trying to figure out how to do this in AntBuilder where there is limited documentation, I created a second shell script that executed the desired shell script in the background instead.

    #!/bin/bash
    
    command="./scriptname.sh  $1 $2 $3 $4"
    
    nohup $command > /dev/null 2>&1 &