Skip to content
Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Gradle Cargo plugin

The plugin provides deployment capabilities for web applications to local and remote containers in any given Gradle build by leveraging the Cargo Ant tasks. It extends the War plugin.


To use the Cargo plugin, include in your build script:

apply plugin: 'cargo'

The plugin JAR needs to be defined in the classpath of your build script. You can either get the plugin from the GitHub download section or upload it to your local repository. To define the Cargo dependencies please use the cargo configuration name in your dependencies closure. Remote deployment functionality will only work with a Cargo version >= 1.1.0 due to a bug in the library. Please see CARGO-962 for more information.

buildscript {
    repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'GitHub'
            addArtifactPattern '[module]-[revision].[ext]'

    dependencies {
        classpath ':gradle-cargo-plugin:0.1'

dependencies {
    def cargoVersion = '1.1.0'
    cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",


The Cargo plugin defines the following tasks:

  • cargoDeployRemote: Deploys web application to remote container.
  • cargoUndeployRemote: Undeploys a web application from remote container.
  • cargoRedeployRemote: Redeploys web application to remote container.
  • cargoStartLocal: Starts the local container and deploys web application to it.
  • cargoStopLocal: Stops local container.

Project layout

The Cargo plugin uses the same layout as the War plugin.

Convention properties

The Cargo plugin defines the following convention properties in the cargo closure::

  • containerId: The container ID you are targeting. Please see the list of supported containers on the Cargo website.
  • port: The TCP port the container responds on (defaults to 8080).
  • context: The URL context the container is handling your web application on (defaults to WAR name).
  • wait: Specifies whether the container should run in the background. When false, this task blocks until the container is stopped (defaults to false).

Within cargo you can define properties for remote containers in a closure named remote:

  • hostname: The hostname of the remote container.
  • username: The username credential for the remote container (optional).
  • password: The password credential for the remote container (optional).

Within cargo you can define properties for local containers in a closure named local:

  • logLevel: The log level to run the container with (optional). The valid levels are low, medium and high.
  • homeDir: The home directory of your local container.


cargo {
    containerId = 'tomcat6x'
    port = 9090
    context = 'myawesomewebapp'

    remote {
        hostname = ''
        username = 'superuser'
        password = 'secretpwd'

    local {
        homeDir = file('/home/user/dev/tools/apache-tomcat-6.0.32')

Project properties

The convention properties can be overridden by project properties via or -P command line parameter:

  • Overrides the convention property containerId.
  • cargo.port: Overrides the convention property port.
  • cargo.context: Overrides the convention property context.
  • cargo.wait: Overrides the convention property wait.
  • cargo.hostname: Overrides the convention property hostname.
  • cargo.username: Overrides the convention property username.
  • cargo.password: Overrides the convention property password.
  • cargo.log.level: Overrides the convention property logLevel.
  • cargo.home.dir: Overrides the convention property homeDir.
Something went wrong with that request. Please try again.