Good tutorial on Ant/Webapplications/Tomcat

G

Gerbrand

Hello,

I want to set up a Ant build.xml file for webapplications.
I want to be able to create .war files automatically, and deploy them to
tomcat.

With ant, I have experience, and I know tomcat.
Can anyone point me to a good tutoral or website with documention how to
do this?
The website of ant is not very descriptive and using google I found lots
of documention, but all seem incomplete or out-dated.
 
M

Mindundi

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)
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Gerbrand said:
I want to set up a Ant build.xml file for webapplications.
I want to be able to create .war files automatically, and deploy them to
tomcat.

With ant, I have experience, and I know tomcat.
Can anyone point me to a good tutoral or website with documention how to
do this?
The website of ant is not very descriptive and using google I found lots
of documention, but all seem incomplete or out-dated.

ant comes with docs.

My experience is that the documentation of tasks is sufficient
to use them.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top