This page last changed on Apr 30, 2011 by alitokmen.
Maven 2 plugin
This page is dedicated for the Maven 1 plugin (the old Maven). There's also a Maven2/Maven3 plugin, and that one is very probably what you're looking for.

Installation

To automatically install the plugin, type the following on a single line:

maven plugin:download
  -DgroupId=org.codehaus.cargo
  -DartifactId=cargo-maven-plugin
  -Dversion=X.X(.X)

where X.X(.X) is the release number you want to install (0.6 is the first available).

Note that for versions earlier or equal to 0.7 you'll need to use a group id of cargo instead of org.codehaus.cargo.

Plugin goals

goal description
cargo:start Starts all containers defined by the cargo.containers property
cargo:stop Stops all containers defined by the cargo.containers property

Plugin properties

Property name Required? Description Default
cargo.containers A list of containers ids that specifies on which containers to apply the goal. If this property is empty the Maven plugin will do nothing. You must define for each containerName the corresponding settings. empty
cargo.zipUrlInstaller.<installerId>.installUrl URL from where the container archive can be downloaded. empty
cargo.zipUrlInstaller.<installerId>.installDir The path where the container will be downloaded and extracted. empty
cargo.proxy.host Proxy hostname (IP or server name). ${maven.proxy.host}
cargo.proxy.port Proxy port. ${maven.proxy.port}
cargo.proxy.user Proxy username. ${maven.proxy.user}
cargo.proxy.password Proxy password. ${maven.proxy.password}
cargo.proxy.excludehosts A list of hosts to bypass the proxy on (if any). These should be separated with the vertical bar character '|'. Only in Java 1.4 does FTP use this list. empty
cargo.container.wait Whether Maven should block after the container is started or not true
cargo.container.<containerName>.containerId The container id. empty
cargo.container.<containerName>.home The path where the container is installed. empty
cargo.container.<containerName>.zipUrlInstaller The id of a zipUrLInstaller. empty
cargo.container.<containerName>.output The path for the file to which output of the container should be written. empty
cargo.container.<containerName>.log The path for the cargo log file. empty
cargo.container.<containerName>.timeout Timeout (in milliseconds) to wait to see if the container is started/stopped. empty
cargo.container.<containerName>.deployables A list of deployable Ids. Each deployable must be defined using the deployables settings. empty
cargo.container.<containerName>.config.type The type to differentiate the configuration from others for the specified container.Currently the only type supported by cargo is : standalone. empty
cargo.container.<containerName>.config.home The home directory for the configuration of the container. empty
cargo.container.<containerName>.config.standalone.servlet.port Port on which the Servlet/JSP container will listen to. empty
cargo.container.<containerName>.config.standalone.hostname Host name on which the container will listen to. empty
cargo.container.<containerName>.config.standalone.logging Level representing the quantity of information we wish to log. Valid values are low | medium | high. empty
cargo.container.<containerName>.config.standalone.jvmargs JVM args to be used when starting/stopping containers. empty
cargo.container.<containerName>.start.output The path for the file to which output of the container should be written when it starts. empty
cargo.container.<containerName>.start.log The path for the cargo log file when the start action is called for this container. empty
cargo.container.<containerName>.stop.output The path for the file to which output of the container should be written when it stops. empty
cargo.container.<containerName>.stop.log The path for the cargo log file when the stop action is called for this container. empty
cargo.container.<containerName>.sysproperties A list of system properties to be passed to the container, separated by space. Each property is described in a sub property. Example:

cargo.container.tomcat.sysproperties = sysprop1 sysprop2
sysprop1 = foo
sysprop2 = bar

empty
cargo.container.<containerName>.config.standalone.orion.rmi.port Port for the Orion RMI server. (Orion 1x, 2x or Oc4j 9x) empty
cargo.container.<containerName>.config.standalone.tomcat.shutdown.port TCP/IP port number on which this server waits for a shutdown command. (Tomcat 4x or 5x) empty
cargo.deployable.<deployableId>.type Deployable type : war | ear. empty
cargo.deployable.<deployableId>.file Absolute path to the deployable file (or the expanded webapp directory). empty
Be Careful
Exactly one of cargo.container.<containerName>.home and cargo.container.<containerName>.zipUrlInstaller must defined.

Samples

All properties sample (incoherent settings)

cargo.containers = myresin,myorion,myjetty
cargo.zipUrlInstaller.myresin.installUrl = http://www.caucho.com/download/resin-3.0.9.zip
cargo.zipUrlInstaller.myresin.installDir = $\{maven.build.dir}/installs
cargo.proxy.host = myproxy.mycompany.com
cargo.proxy.port = 1080
cargo.proxy.user = vmassol
cargo.proxy.password = somepassword
cargo.proxy.excludehosts = fozbot.corp.sun.com\|\*.eng.sun.com
cargo.container.myresin.containerId = resin3x
cargo.container.myresin.home = c:/apps/resin/
cargo.container.myContainer.zipUrlInstaller = myContainerInstallerId
cargo.container.myContainer.output = $\{maven.build.dir}/myContainer/logs/container.log
cargo.container.myContainer.log = $\{maven.build.dir}/myContainer/logs/cargo.log
cargo.container.myContainer.timeout = 120000
cargo.container.myContainer.deployables = myEarId, myWarId
cargo.container.myContainer.config.type = standalone
cargo.container.myContainer.config.home = $\{maven.build.dir}/myContainer/config
cargo.container.myContainer.config.standalone.servlet.port = 8280
cargo.container.myContainer.config.standalone.hostname = myserver
cargo.container.myContainer.config.standalone.logging = high
cargo.container.myContainer.config.standalone.jvmargs = -Xmx64m -Xms2m
cargo.container.myContainer.start.output = $\{maven.build.dir}/myContainer/logs/container-start.log
cargo.container.myContainer.start.log = $\{maven.build.dir}/myContainer/logs/cargo-start.log
cargo.container.myContainer.stop.output = $\{maven.build.dir}/myContainer/logs/container-stop.log
cargo.container.myContainer.stop.log = $\{maven.build.dir}/myContainer/logs/cargo-stop.log
cargo.container.myContainer.config.standalone.orion.rmi.port = 25791
cargo.container.myContainer.config.standalone.tomcat.shutdown.port = 8205
cargo.deployable.myDeployableId.type = war
cargo.deployable.myDeployableId.file = $\{maven.war.build.dir}/$\{maven.war.final.name}

Minimal settings to start and stop a container

Example with tomcat already installed:

maven.xml
<preGoal name="cargo:start">
  <ant:mkdir dir="$\{maven.build.dir}/myTomcat/config"/>
</preGoal>
project.properties
cargo.containers = myTomcat

cargo.container.myTomcat.containerId = tomcat5x
cargo.container.myTomcat.home = C:/Programs/web/jakarta-tomcat-5.0
cargo.container.myTomcat.config.type = standalone
cargo.container.myTomcat.config.home = $\{maven.build.dir}/myTomcat/config
cargo.container.myTomcat.config.standalone.servlet.port = 8280
cargo.container.myTomcat.config.standalone.logging = high

IDE support

Netbeans

There's a Netbeans module working with Mevenide for Netbeans. The module adds a panel into the Maven project's customizer. It eases the setup of the Maven plugin properties and visualizes the current settings.

The current version of the module is 1.0, it works with Mevenide 0.8.1 and later and Netbeans 4.1 and Netbeans 5.0 beta. It can be downloaded here. After download, start Netbeans and install the module through the AutoUpdate Center.

Sample screenshot


cargomaven1.png (image/png)
cargomaven2.png (image/png)
Document generated by Confluence on Aug 13, 2011 20:11