tags:

views:

14

answers:

1

I have the following ant snippet

 <macrodef name="webapp.start">
    <attribute name="name" />
    <sequential>
        <!--deploy-->
        <antcall target="webapp.@{name}" />
        <!--start server-->
        <antcall target="tomcat-server-start" />
        <!--go to URL-->
        <exec executable="firefox" os="Linux" >
            <arg line="-new-tab http://localhost:${tomcat.port}/@{name}" />
        </exec>
    </sequential>
</macrodef>

It starts the server but does not open the browser. If I put the exec task in a seperate target and run it, it works fine. I am guessing that starting the server which is a process that does not end, the next one does not begin. How to do I overcome this issue. Is there a way I can start exec as a sperate process.

+1  A: 

I am guessing that starting the server which is a process that does not end, the next one does not begin

I would spend a minute making sure this is the case. Use pgrep or ps to figure out what your processes are up to.

If you confirm the server never finishes, I would have the command "tomcat-server-start" start in the background (by postfixing the shell command with &), unless it is a big deal if firefox starts before tomcat-server. Alternatively, use a parallel block within your sequential block, like this:

<macrodef name="webapp.start">
    <attribute name="name" />
    <sequential>
        <!--deploy-->
        <antcall target="webapp.@{name}" />
        <parallel>
            <!--start server-->
            <antcall target="tomcat-server-start" />
            <!--go to URL-->
            <exec executable="firefox" os="Linux" >
                <arg line="-new-tab http://localhost:${tomcat.port}/@{name}" />
            </exec>
        </parallel>
    </sequential>
</macrodef>
louisgab
My server had to start before the browser launched. So I added a waitfor task inside parallel. Thanks for your help.