0

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.

4

2 回答 2

1

脚本.sh

#!/bin/bash

cat > foo.conf << EOF
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    ServerName localhost
</VirtualHost>
EOF

构建.gradle

task external << {
    ant.exec(spawn:'true', executable: "${project.projectDir}/script.sh") 
}

build.gradle并且script.sh必须位于此解决方案中的同一文件夹中。您需要提供executable.

于 2014-06-20T09:31:58.623 回答
0

我没有尝试在文档有限的 AntBuilder 中弄清楚如何执行此操作,而是创建了第二个 shell 脚本,它在后台执行所需的 shell 脚本。

#!/bin/bash

command="./scriptname.sh  $1 $2 $3 $4"

nohup $command > /dev/null 2>&1 &
于 2014-06-26T01:40:25.843 回答