ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iwan" <j...@i-ware.net>
Subject RE: how to start jboss in the ant
Date Tue, 29 Jul 2003 15:58:07 GMT
Here's how I did it using the spawn-task that was posted recently.

    <!--
####################################################################-->
    <!-- ############################ JBoss tasks
###########################-->
    <!--
####################################################################-->

    <!-- ===================================================================
-->
    <!-- Starts JBoss running the server ${jboss.host}
-->
    <!--
-->
    <!-- Specify the property jboss.new.process as 'start' and jboss will
-->
    <!-- start in a new window.
-->
    <!-- ===================================================================
-->
    <target name="start.jboss" depends="check_jboss_running"
unless="jboss_already_running">
        <echo>+-----------------------------+</echo>
        <echo>|                             |</echo>
        <echo>| S T A R T I N G   J B O S S |</echo>
        <echo>|                             |</echo>
        <echo>+-----------------------------+</echo>
        <echo></echo>
        <echo>This will take some time, possibly up to a minute.</echo>
        <echo></echo>

	  <!-- startJBoss.bat is some batch file that looks like "%1 %2 %3
%4 %5", that's it. -->
	  <!-- The first param is to either start Jboss' run.bat directly or
thru the start   -->
	  <!-- command from Windows, this is handled by the property
jboss.new.process	  -->
        <spawn dir="${basedir}" executable="startJBoss.bat">
            <arg line="${jboss.new.process} ${jboss.root.dir}/bin/run.bat -c
${jboss.server}"/>
        </spawn>

	  <!-- This property is used in the stop.jboss target to identify
whether jboss was   -->
	  <!-- started using this build script or not. You might not want to
stop jboss when  -->
	  <!-- it wasn't started from the build script.
-->
        <property name="started_by_ant" value="true"/>
        <waitfor maxwait="60" maxwaitunit="second">
            <and>
                <socket server="${jboss.host}" port="${jboss.port}"/>
                <http
url="http://${jboss.host}:${jboss.port}/jmx-console/index.jsp"/>
            </and>
        </waitfor>
        <echo>+-----------------------------+</echo>
        <echo>| J B O S S   S T A R T E D   |</echo>
        <echo>+-----------------------------+</echo>
    </target>
    
    <target name="check_jboss_running">
        <condition property="jboss_already_running" value="true">
            <and>
                <socket server="${jboss.host}" port="${jboss.port}"/>
                <http
url="http://${jboss.host}:${jboss.port}/jmx-console/index.jsp"/>
            </and>
        </condition>
        <echo>JBoss is already running on ${jboss.host}:${jboss.port} -
[${jboss_already_running}]</echo>
    </target>
    
    <!-- ===================================================================
-->
    <!-- Stops JBoss running on the server ${jboss.host}
-->
    <!-- ===================================================================
-->
    <target name="stop.jboss" if="started_by_ant">
        <echo>+-----------------------------+</echo>
        <echo>|                             |</echo>
        <echo>| S T O P P I N G   J B O S S |</echo>
        <echo>|                             |</echo>
        <echo>+-----------------------------+</echo>
        <echo></echo>
        <spawn dir="${jboss.root.dir}\bin"
executable="${jboss.root.dir}\bin\shutdown.bat">
            <arg line="${jboss.host} ${jboss.port}"/>
        </spawn>
        <echo>+-----------------------------+</echo>
        <echo>| J B O S S   S T O P P E D   |</echo>
        <echo>+-----------------------------+</echo>
    </target>

    <target name="fail.and.stop.jboss" if="jboss.timeout">
        <echo>+--------------------------+</echo>
        <echo>| J B O S S   F A I L E D  |</echo>
        <echo>+--------------------------+</echo>
        <antcall target="stop.jboss"/>
        <fail message="JBoss is not running correctly, possibly due to a
deployment error" if="jboss.timeout"/>
    </target>

Iwan

> -----Original Message-----
> From: yinhua [mailto:cnyinhua@hotmail.com] 
> Sent: Wednesday, July 30, 2003 6:50 AM
> To: user@ant.apache.org
> Subject: how to start jboss in the ant
> 
> 
> hi, all
> I just want to start the JBoss in the ant build.xml, but I 
> don't want to = use the Cactus. Does someboby know how to do 
> this. I have heard of = Spawn, but I haven't seen this task 
> in the ant build. How about this = one? Any help will be 
> welcome. Thanks frank
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message