From 11ad3a4f1a9e139abbf29ce81303598ed8a6cf9b Mon Sep 17 00:00:00 2001 From: Tom Liao Date: Sat, 19 Apr 2014 23:09:07 -0700 Subject: [PATCH] Add pingUrl and pingTimeout --- .../cargo/convention/Deployable.groovy | 2 ++ .../local/LocalCargoContainerTask.groovy | 26 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/org/gradle/api/plugins/cargo/convention/Deployable.groovy b/src/main/groovy/org/gradle/api/plugins/cargo/convention/Deployable.groovy index 0543bb0..9808207 100644 --- a/src/main/groovy/org/gradle/api/plugins/cargo/convention/Deployable.groovy +++ b/src/main/groovy/org/gradle/api/plugins/cargo/convention/Deployable.groovy @@ -23,4 +23,6 @@ package org.gradle.api.plugins.cargo.convention class Deployable implements Serializable { File file String context + String pingUrl + Integer pingTimeout } diff --git a/src/main/groovy/org/gradle/api/plugins/cargo/tasks/local/LocalCargoContainerTask.groovy b/src/main/groovy/org/gradle/api/plugins/cargo/tasks/local/LocalCargoContainerTask.groovy index 306aabf..ae7b36f 100755 --- a/src/main/groovy/org/gradle/api/plugins/cargo/tasks/local/LocalCargoContainerTask.groovy +++ b/src/main/groovy/org/gradle/api/plugins/cargo/tasks/local/LocalCargoContainerTask.groovy @@ -135,6 +135,9 @@ class LocalCargoContainerTask extends AbstractCargoContainerTask { + (deployable.file == null ? "null" : deployable.file.canonicalPath) + " does not exist") } + if(deployable.pingTimeout && !deployable.pingUrl) { + throw new InvalidUserDataException("Deployable has ping timeout, but no ping url") + } } logger.info "Deployable artifacts = ${getDeployables().collect { it.file.canonicalPath }}" @@ -189,8 +192,27 @@ class LocalCargoContainerTask extends AbstractCargoContainerTask { getDeployables().each { deployable -> if(deployable.context) { - ant.deployable(type: getDeployableType(deployable).filenameExtension, file: deployable.file) { - ant.property(name: AbstractCargoContainerTask.CARGO_CONTEXT, value: deployable.context) + if (deployable.pingUrl) { + if (deployable.pingTimeout) { + ant.deployable(type: getDeployableType(deployable).filenameExtension, + file: deployable.file, + pingUrl: deployable.pingUrl, + pingTimeout: deployable.pingTimeout) { + ant.property(name: AbstractCargoContainerTask.CARGO_CONTEXT, value: deployable.context) + } + } + else { + ant.deployable(type: getDeployableType(deployable).filenameExtension, + file: deployable.file, + pingUrl: deployable.pingUrl) { + ant.property(name: AbstractCargoContainerTask.CARGO_CONTEXT, value: deployable.context) + } + } + } + else { + ant.deployable(type: getDeployableType(deployable).filenameExtension, file: deployable.file) { + ant.property(name: AbstractCargoContainerTask.CARGO_CONTEXT, value: deployable.context) + } } } else {