You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Kent Larsson <ke...@gmail.com> on 2009/01/09 21:01:34 UTC
Build war file and deploy to local Tomcat using Ant and Ivy
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
Re: Build war file and deploy to local Tomcat using Ant and Ivy
Posted by Les Hazlewood <lh...@apache.org>.
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 <ke...@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
>
Re: Build war file and deploy to local Tomcat using Ant and Ivy
Posted by Hugo Pinto <hs...@gmail.com>.
Hello Kent,
Though I guess Les Hazlewood's response answers your question fairly well, I
would recommend taking a peek at "Ant in Action", by Manning.
It has a step by step example exactly for this, plus a plethora of other
nice tips for project automation and config management using ANT and Ivy.
Best,
--
Hugo Pinto
Artificial Intelligence, Computational Linguistics and Computer Games
http://www.hugopinto.net
2009/1/9 Kent Larsson <ke...@gmail.com>
> 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
>