Hi Kent,

You don't pull servlet-api from tomcat - you would configure one of Ivy's
resolvers to point to a repository - say, the public Maven 2 repository.
Then it auto-downloads it if necessary.

Here is a line in my ivy.xml file that does exactly this:

<dependency org="javax.servlet" name="servlet-api" rev="2.4"
conf="someConf,anotherConf"/>

This assumes you have an ivy resolver that 'knows' about the m2 repo.
Typically this is declared in an ivysettings.xml file (this is documented in
the ivy documentation).

After you verify your build is pulling the servlet api jar and you can
compile everything, then you can build your .war file via Ant's built-in
<war> ant task.

I like to have a "deploy-exploded" task that unzips this already-built war
file directly into ${env.CATALINA_HOME}/webapps.  This assumes you have the
CATALINA_HOME environment variable set, and somewhere in your ant file, you
have this line:

<property environment="env"/>

which makes environment variables accessible to ant (prefixed with 'env.').

For example:

<target name="deploy-exploded" depends="war">
    <echo>Deploying ${projectName} application to Tomcat...</echo>
    <unwar src="${war.file}"
dest="${env.CATALINA_HOME}/webapps/${projectName}"/>
    <touch
file="${env.CATALINA_HOME}/webapps/${projectName}/WEB-INF/web.xml"/>
</target>

HTH,

Les

On Fri, Jan 9, 2009 at 3:01 PM, Kent Larsson <kent.lars...@gmail.com> wrote:

> Hi,
>
> I'm wondering if there are any examples or "best practices" out there
> for building a web application and deploy it to a local tomcat
> installation using Ant and Ivy?
>
> I would use Ivy to resolve dependencies and amongst them I want to use
> the servlet-api.jar from Tomcat, which I don't know how to do.
>
> Any and all help highly appreciated!
>
> Regards, Kent
>

Reply via email to