A Maven 2 plugin that wraps the Cargo Java API
| Functional tests The usage of Cargo for executing functional tests on a container does not need this m2 plugin. You should directly use the Cargo Java API from your Java unit test classes (JUnit, TestNG, etc), as described on the Functional testing page. |
Table of Contents
This page documents the following:
- Installation: explains how to install the plugin
- Features: explains how to use the plugin on several use cases
- Configuration: provide reference documentation for all configuration options
- Tips: tips for using the plugin
Installation
There is no installation necessary. The Cargo artifacts are hosted on ibiblio. Note that you may also find older artifacts on ibiblio but those shouldn't be used and won't work with this plugin.
Note that the Cargo project has a snapshot repository on Codehaus. If you want use snapshot versions of the Cargo m2 plugin you'll need to add this definition in your POM or settings file:
Then configure the Cargo plugin by specifyin a SNAPSHOT version. For example to use version 0.3-SNAPSHOT you would write in your POM:
Features
As usual the best way to learn to use a tool is through examples. We have several sample projects that we use as our internal functional tests suite. We'd really recommend that you check them out. In addition here are the typical uses cases covered by the plugin:
Goals |
Description |
|---|---|
|
Start a container and optionally deploy deployables (WAR, EAR, etc) |
|
Stop a container |
|
Deploy a deployable to a running container |
|
Undeploy a deployable from a running container |
|
Start a deployable already installed in a running container |
|
Stop a deployed deployable without undeploying it |
|
Undeploy and deploy again a deployable |
|
Merge several WAR files into one |
The configuration elements are described in the configuration section.
Configuration
These are the various XML configuration elements that you can use to configure the Cargo Maven2 plugin. Make sure you also check the use cases which show how to use them.
Top level configuration elements |
Description |
Mandatory? |
Default value |
|---|---|---|---|
Definition of a Configuration |
|
Defaults to a standalone configuration if the container is of type local and a runtime one if it's of type remote |
|
Definition of a Container |
|
Defaults to a Jetty 5.x container if not specified |
|
Definition of a Deployer |
|
Defaults to a deployer matching the container's type if none is specified (installed local deployer for an installed container, remote deployer for a remote container and embedded local deployer for an embedded container) |
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
List of modules to deploy when the container is started. You specify each module using a |
|
If no deployable is specified and the project's packaging is war, ear or ejb and there is no deployer specified then the generated artifact is added automatically to the list of deployables to deploy |
|
|
For standalone configuration this is the location where Cargo will create the configuration and for existing configuration this is where it is located |
|
|
|
Full classname of a custom configuration implementation to use. In that case the custom configuration is registered with the |
|
Defaults to the Cargo-provided implementation if not specified |
Values to use for various Configuration properties |
|
||
|
Configuration's type. Valid values are |
|
|
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
|
If true then the file specified by |
|
False |
|
Id of the container to use. Valid values can be found in the description page for each container |
|
|
|
List of extra dependencies that will be added to the container execution classpath. |
|
No default |
|
Location where the container is installed |
|
No default, user must define either a |
|
Full classname of a custom container implementation to use. In that case, the custom container is registered with the |
|
Defaults to the Cargo-provided implementation if not specified |
|
Path to a file where Cargo logs are saved |
|
No logs are saved |
|
Path to a file where container logs are saved |
|
No logs are saved |
List of |
|
No default |
|
The timeout after which Cargo reports an error if the container is not started |
|
120000 ms (2 minutes) |
|
Container's type. Valid values are |
|
Default value is |
|
Defines the location of a container distribution zip that will be downloaded and installed |
|
No default, a home directory for the container has to be defined in that case |
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
|
A list of deployables that are going to be deployed in the container when it is started |
|
No default |
|
TODO |
|
No default |
|
TODO |
|
|
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
|
Maven artifact id for the module. This artifact id must match either the project's artifact id if your project generates a J2EE artifact (WAR, EAR, EJB and RAR) or it must match a specified |
|
Defaults to the project's artifact id |
|
Maven group id for the module. This group id must match either the project's group id if your project generates a J2EE artifact (WAR, EAR, EJB and RAR) or it must match a specified |
|
Defaults to the project's group id |
|
TODO |
|
No default |
|
Path location where the module can be found |
|
Default's to the project's generated artifact location or to the specified |
|
TODO |
|
No default |
User-defined properties of a deployable. |
|
No default |
|
|
Maven type for the module. This type must match either the project's packaging if your project generates a J2EE artifact (WAR, EAR, EJB and RAR) or it must match a specified |
|
Defaults to the project's packaging |
|
Deployable Type |
Description |
Mandatory? |
Default value |
|---|---|---|---|---|
|
WAR |
The context name to use when deploying this web application. |
|
If not specified by the user, then the default context name is computed from the name of WAR itself (without the file extension) or |
<war> |
WAR |
The path of the WAR being deployed. |
|
Default's to the project's generated artifact location |
<ear> |
EAR |
The path of the EAR being deployed. |
|
Default's to the project's generated artifact location |
<name> |
EAR |
The name of EAR deployable (it can be anything, there's no special rule). |
|
If not specified, it is computed from the EAR's file name (removing the filename extension) or |
<ejb> |
EJB |
The path of the EJB being deployed. |
|
Default's to the project's generated artifact location |
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
|
Maven's artifact id. This artifact id must match a specified |
|
Defaults to the project's artifact id |
|
Maven's group id. This group id must match a specified |
|
Defaults to the project's group id |
|
Maven's type. This type must match a specified |
|
Defaults to the project's packaging |
<location> |
The path of a folder or a jar file you wish to add to deployable classpath. This element can be used to explicitly add entries to the classpath. For example: |
|
If the groupId and artifactId match those of the project then the deployable is the artifact generated by the project. Otherwise the location is the location of the dependency in your local respository. |
|
Description |
Mandatory? |
Default value |
|---|---|---|---|
|
TODO |
|
TODO |
|
TODO |
|
No default |
|
TODO |
|
No default |
Tips
- Starting mutiple containers conditionally
- Starting Tomcat in security mode
- How to get Tomcat 5 workgin with the Java 5 XML Parsers
Starting mutiple containers conditionally
Maven 2 supports the notion of profiles which can be used with Cargo to decide for example when to run tests on a specific container. Here's how you could use the Cargo m2 plugin to that effect:
Then to start the tomcat 5.x container you would type mvn -P tomcat5x install. if you want to start both containers you would type mvn -P tomcat5x,orion2x install.
If you want to define a profile as the default you can use the <activation> element with an activation strategy. For example if you want a profile to be always on, use:
Starting Tomcat in security mode
Cargo supports passing system properties Passing system properties. So, to start Tomcat in security mode, you need to specify two system properties:
- java.security.manager
- java.security.policy
For instance,
How to get Tomcat 5 workgin with the Java 5 XML Parsers
Tip submitted by Ben P.
Imagine that you have some XML jars in the common/endorsed folder of Tomcat and you have edited your catalina.bat file to specify some extra JVM opts to specify the XML parser. Here's how to achieve the same using Cargo:
This shows how to add classpath elements to a Cargo container using the <dependencies> element.