Skip to content

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo

License

Notifications You must be signed in to change notification settings

pipelineoptika/gradle-cargo-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gradle Cargo plugin

Cargo Logo

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.

Usage

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 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }

    dependencies {
        classpath 'bmuschko:gradle-cargo-plugin:0.3'
    }
}

dependencies {
    def cargoVersion = '1.1.1'
    cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
          "org.codehaus.cargo:cargo-ant:$cargoVersion",
          'jaxen:jaxen:1.1.1'
}

Tasks

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.
  • cargoRunLocal: Starts the local container, deploys web application to it and wait for the user to press CTRL + C to stop.
  • cargoStartLocal: Starts the local container, deploys web application to it and then do other tasks (for example, execute tests).
  • 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).

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

  • protocol: The protocol of the remote container (defaults to http).
  • 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.

Example

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

    remote {
        hostname = 'cloud.internal.it'
        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 gradle.properties or -P command line parameter:

  • cargo.container.id: Overrides the convention property containerId.
  • cargo.port: Overrides the convention property port.
  • cargo.context: Overrides the convention property context.
  • cargo.protocol: Overrides the convention property protocol.
  • 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.

About

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 100.0%