可能需要你的帮助:
尝试在Groovy中执行ant任务,这样它就不会等待脚本的响应(即在后台运行)
我试过以下两种方法,但都没有成功
//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") 对如何做到这一点有什么建议吗?我搜索过google,但是找不到Groovy的任何好例子。
谢谢各位我很感激你们的帮助。
发布于 2014-06-26 01:40:25
在文档有限的AntBuilder中,我创建了第二个shell脚本,它在后台执行所需的shell脚本,而不是试图找出如何做到这一点。
#!/bin/bash
command="./scriptname.sh $1 $2 $3 $4"
nohup $command > /dev/null 2>&1 &发布于 2014-06-20 09:31:58
script.sh
#!/bin/bash
cat > foo.conf << EOF
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
</VirtualHost>
EOFbuild.gradle
task external << {
ant.exec(spawn:'true', executable: "${project.projectDir}/script.sh")
}build.gradle和script.sh必须位于此解决方案中的同一文件夹中。您需要提供到executable的完整路径。
https://stackoverflow.com/questions/24316850
复制相似问题