Skip to content

Instantly share code, notes, and snippets.

@SQiShER
Last active August 29, 2015 13:57
Show Gist options
  • Save SQiShER/9416013 to your computer and use it in GitHub Desktop.
Save SQiShER/9416013 to your computer and use it in GitHub Desktop.
Gradle Cargo Plugin configuration example for isolated containers
def availablePortFinder = AvailablePortFinder.createPrivate()
def tomcatDownloadUrl = 'http://.../apache-tomcat-7.0.50.zip'
def cargoHome = "$buildDir/cargo"
// ...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.4.5'
}
}
apply plugin: 'cargo'
cargo {
containerId = 'tomcat7x'
deployable {
// ...
}
local {
homeDir = file(cargoHome)
configHomeDir = file(cargoHome)
installer {
installUrl = tomcatDownloadUrl
downloadDir = file("$buildDir/download")
extractDir = file("$buildDir/extract")
}
containerProperties {
property 'cargo.servlet.port', availablePortFinder.nextAvailable
property 'cargo.tomcat.ajp.port', availablePortFinder.nextAvailable
property 'cargo.rmi.port', availablePortFinder.nextAvailable
}
}
}
task createCargoHome() {
doLast {
if (!file(cargoHome).exists() && !file(cargoHome).mkdirs()) {
println "Failed to create directory '${cargoHome}'"
}
}
}
cargoStartLocal.finalizedBy cargoStopLocal
cargoStartLocal.dependsOn createCargoHome
// ...
@seanf
Copy link

seanf commented Aug 21, 2014

Thanks for the example. I tried to use it, but I couldn't get it to work.

I had to fill in a few things to get as far as I did:

def tomcatDownloadUrl = 'http://mirror.ventraip.net.au/apache/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.zip'

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

I also had to change the version of gradle-cargo-plugin to 1.4.1 or 1.5, because 1.4.5 could not be found.

But either way, I get this error:

Cannot get property 'canonicalPath' on null object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment