Add the following to build.xml to control starting/stopping/and reseting the application through ant
<!-- ==========================================================
start
start the web application on the server
========================================================== -->
<target name="start" description="start the webapp" depends="init">
<echo level="info">
***********************************************************************
*
* Attempting to start ${server.url}${webapp.path}
*
***********************************************************************
</echo>
<start url="${server.manager.url}"
username="${server.manager.username}"
password="${server.manager.password}"
path="${webapp.path}" />
</target>
<!-- ==========================================================
stop
stop the web application on the server
========================================================== -->
<target name="stop" description="stop the webapp" depends="init">
<echo level="info">
***********************************************************************
*
* Attempting to stop ${server.url}${webapp.path}
*
***********************************************************************
</echo>
<stop url="${server.manager.url}"
username="${server.manager.username}"
password="${server.manager.password}"
path="${webapp.path}" />
</target>
<!-- ==========================================================
reset
stop then start the server
========================================================== -->
<target name="reset" description="stop then start the webapp">
<antcall target="stop"/>
<antcall target="start"/>
</target>
start
start the web application on the server
========================================================== -->
<target name="start" description="start the webapp" depends="init">
<echo level="info">
***********************************************************************
*
* Attempting to start ${server.url}${webapp.path}
*
***********************************************************************
</echo>
<start url="${server.manager.url}"
username="${server.manager.username}"
password="${server.manager.password}"
path="${webapp.path}" />
</target>
<!-- ==========================================================
stop
stop the web application on the server
========================================================== -->
<target name="stop" description="stop the webapp" depends="init">
<echo level="info">
***********************************************************************
*
* Attempting to stop ${server.url}${webapp.path}
*
***********************************************************************
</echo>
<stop url="${server.manager.url}"
username="${server.manager.username}"
password="${server.manager.password}"
path="${webapp.path}" />
</target>
<!-- ==========================================================
reset
stop then start the server
========================================================== -->
<target name="reset" description="stop then start the webapp">
<antcall target="stop"/>
<antcall target="start"/>
</target>
With an application already running
>
ant stop
[stop] OK - Stopped application at context path /JavaPersistence
[stop] OK - Stopped application at context path /JavaPersistence
Verify through the tomcat manager that the application has been stopped. Then run the task again
>
ant stop
[stop] OK - Stopped application at context path /JavaPersistence
[stop] OK - Stopped application at context path /JavaPersistence
No need for error catching here. Now start the application with
>
ant start
[start] OK - Started application at context path /JavaPersistence
[start] OK - Started application at context path /JavaPersistence
And for completeness
>
ant start
[start] OK - Started application at context path /JavaPersistence
[start] OK - Started application at context path /JavaPersistence
So now this works as expected. Finally, trying 'resetting' the application
> ant reset
If everything is working out nicely, add install to the 'all' task.
<target name="all"
[...]>
[...]
<antcall target="zip"/>
<antcall target="install"/>
</target>
[...]
<antcall target="zip"/>
<antcall target="install"/>
</target>
Now test with
> ant all
If everything works
> ant svn inc.build.minor
commit
Start/Stop Tasks