问题
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