| Automated deployment with Cargo and Maven - a short primer |
|
|
|
| Tuesday, 29 December 2009 07:18 |
|
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 (1)
![]() Write comment
|
Agile ALL Annotations Artifactory Automated Deployment Automated Testing BDD Bugzilla Build Automation Cargo Code Coverage Code Quality Code Reviews Continuous Integration Continuum Distributed Builds EasyB Eclipse Grails Groovy Hibernate Hudson Humour Integration Tests JasperReports Java Javascript JDave JUnit Lucene Maven Mock Objects Mockito Mylyn Nexus Performance PMD Profiling Rome RSS Selenium Smack API Subversion TDD TeamCity Testing Trac training Unit Testing Unit Tests