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 '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'
}
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 pressCTRL + 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.
The Cargo plugin uses the same layout as the War plugin.
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 tohttp
).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 arelow
,medium
andhigh
.homeDir
: The home directory of your local container.
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')
}
}
The convention properties can be overridden by project properties via gradle.properties
or -P
command line parameter:
cargo.container.id
: Overrides the convention propertycontainerId
.cargo.port
: Overrides the convention propertyport
.cargo.context
: Overrides the convention propertycontext
.cargo.protocol
: Overrides the convention propertyprotocol
.cargo.hostname
: Overrides the convention propertyhostname
.cargo.username
: Overrides the convention propertyusername
.cargo.password
: Overrides the convention propertypassword
.cargo.log.level
: Overrides the convention propertylogLevel
.cargo.home.dir
: Overrides the convention propertyhomeDir
.