| Automated deployment with Cargo and Maven - a short primer |
|
|
Cargo is a versatile library that lets you manage, and deploy applications to, a variety of application servers. In this article, we look at how to use Cargo with Maven. If you are starting from scratch, you can use an Archetype to create a Cargo-enabled web application:
Or it is easy to add to an existing configuration - just add the cargo-maven2-plugin to your pom file. The default configuration will deploy the application to an embedded Jetty server:
Then just run mvn cargo:start. However Cargo is designed for deployment, and does not support rapid lifecycle development - use the ordinary Jetty plugin for that. Deploying to a Tomcat instanceYou can run your integration tests against a Tomcat server that Cargo will initialize and configure for the occasion - this is referred to as 'standalone' mode:
Cargo will create a base directory (think CATALINA_BASE) in a directory that you specify. It will use the Tomcat home directory that you provide. At each installation, Cargo will destroy and recreate the base directory. You can also download and install a Tomcat installation as required using the This is a more portable solution which is useful for integration tests Running integration tests with CargoYou can use Cargo to automatically start up a web server to run your integration tests. This means you can run your integration tests on any of the supported servers (Tomcat, Jetty, JBoss, Weblogic,...):
Deploying to an existing serverYou can also deploy to a running application server. You need to use the 'existing' configuration type (
Then you can deploy your application as shown here:
Deploying to a remote serverYou can also deploy to a remote server, using the server-specific remote API (e.g. the HTML manager application for Tomcat). You need to set up a container of type 'remote' and a configuration of type 'runtime':
In the <properties> section, you define server-specific properties (see the Cargo documentation). Then you use Cargo as usual:
Using a dedicated deployer moduleYou can dissociate the build process from the application deployment process by creating a separate Maven module dedicated to deployments. This also makes it easier to build and deploy your WAR file to Nexus on one server, and then deploy to your application server directly on the target machine. To do this, you create a dedicated Maven module. It only needs to contain the Cargo plugin and a dependency on the application to be deployed. The Cargo plugin uses the
The dependencies section contains a reference to the WAR file to be deployed. You can use a property here so that you can pass a version number from the command line:
Bookmark
Email this
Trackback(0)
Comments (3)
![]() written by Aranya, April 20, 2010
Thanx for the sharing above. Just neeeded lil more info regarding
Deploying to a remote server. I am trying to deploy my grails project from hudson to a remote tomcat machine.So is it possible to restart the remote server using this cargo plugin ? Because if I do redeploy on the running machine, it always gets into PermgenSpace and outofmemory error.Thanx in advance. written by Mick, August 11, 2010
Hi,
I have the same needs as Aranya, can you explain in more detail how to deploy a WAR file from hudson to Tomcat6.x using cargo? Hudson has a plugin (which uses cargo as well) but it only supports upto v5.x and so I thought i could use cargo and give it a shot till the plugin gets upgraded. Write comment
|
|