war ant task documentation in Ant manual:
http://ant.apache.org/manual/CoreTasks/war.html
An example I did some time ago:
<target name="dist" depends="compile ,javadoc">
<war file="${dist.home}/${app.name}.war"
webxml="${web.home}/WEB-INF/web.xml">
<fileset dir="${build.home}">
<exclude name="**/web.xml" />
<exclude name="**/*.java" />
<exclude name="**/*.class" />
</fileset>
<lib dir="${basedir}/lib"/>
<classes dir="${build.home}/WEB-INF/classes">
<exclude name="**/*.java"/>
</classes>
</war>
</target>
Note the proper filesets will depend on your environment.
Tomcat tasks examples:
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
<target name="install" depends="dist">
<deploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"
war="${dist.home}/action.war"/>
</target>
<target name="remove">
<undeploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
</target>
-All is configured with a build.properties which assigns ${xxx}.
-You must include catalina-ant.jar (in Tomcat's server/lib folder) in your
classpath
-To remove an application, it's better to stop it before, with the stop task
(there are also start, list,...)
-Tomcat docs (not much) about its Ant tasks:
http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing Manager Commands With Ant
-Sometimes one or more webapp jars get locked and the remove undeploy task
doesn't work properly if you don't restart Tomcat. In that case, change
Tomcat's context.xml to <context antiJARLocking="true"> ... </context> to
prevent this to happen (only in development, as it will slow down things a
bit)