Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I package my web app and tomcat together using maven?

I would like to distribute my application packaged as WAR embedded in Apache Tomcat. That is I want to distribute Tomcat along with my application.

How can this sort of distribution packaging can be done with Maven?

I have seen the Maven Cargo Plugin, but it appears to be geared towards deploying applications in containers locally. Perhaps an additional step over Cargo plugin is what I need. cargo:package appears to be interesting but lacks documentation.

like image 478
Tahir Akhtar Avatar asked Apr 05 '11 15:04

Tahir Akhtar


People also ask

How do I deploy a maven project from Tomcat to eclipse?

Right-click the maven project, click Run As —> Run Configurations menu item. Input clean install tomcat7:deploy in the Goals input text box deploy maven project to tomcat. Click Run button, when you see BUILD SUCCESS in the output console, that means the maven deploy to tomcat server process complete successfully.

What is Tomcat maven plugin?

The Tomcat Maven Plugin provides goals to manipulate WAR projects within the Apache Tomcat servlet container. Or to run your war project with an embedded Apache Tomcat. The run goals give you the opportunity to quickly develop your application without needing to install a standalone Tomcat instance.


1 Answers

Elaborating Tomasz's comment, you can do the following to achieve this.

  1. Download and install tomcat to your local repository.

    mvn install:install-file -DgroupId=org.apache -DartifactId=tomcat -Dversion=7.0.10 -Dpackaging=zip -Dfile=/path/to/file

  2. Use unpack goal of maven dependency plugin to unzip tomcat to a work folder

  3. Use maven assembly plugin to place the application war in webapps folder and create a zip

You can refer to this pom.xml and this assembly descriptor.

like image 64
Raghuram Avatar answered Sep 28 '22 09:09

Raghuram