Run Ant target in background without using spawn=true

别来无恙 提交于 2019-12-22 08:29:07

问题


I would like to start a server in background, go back and execute some other targets, and then stop the server when Ant finishes executing all targets.

I have come up with the following two solutions but they both block Ant from executing the subsequent targets.

Since I want the process to die in the end, I do not want to use spawn="true". Is there any other solution?

<target name="Start_Selenium_Server">
    <java dir="lib" jar="lib/selenium-server-standalone-2.28.0.jar" fork="true">
        <arg line="-singleWindow -userExtensions user-extensions.js"/>
    </java>
</target>   

<target name="Start_Selenium_Server">
    <exec dir="lib" executable="java" newenvironment="true" output="./log/StartSeleniumServer.log">
        <arg line="-jar selenium-server-standalone-2.28.0.jar -singleWindow -userExtensions user-extensions.js" />
    </exec>
</target>   

回答1:


Wrap the call using the parallel task and the daemons nested element

<target name="Start_Selenium_Server">
    <parallel> 
        <daemons>
            <java dir="lib" jar="lib/selenium-server-standalone-2.28.0.jar" fork="true">
               <arg line="-singleWindow -userExtensions user-extensions.js"/>
            </java>
        </daemons>
 <parallel> 
</target> 


来源:https://stackoverflow.com/questions/15348960/run-ant-target-in-background-without-using-spawn-true

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!