bmuschko / gradle-cargo-plugin

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Apache License 2.0
258 stars 61 forks source link

Cargo-base doesn't support Empty password #81

Closed raheel-arif-confiz closed 10 years ago

raheel-arif-confiz commented 10 years ago

I was trying to deploy my application on multiple tomcat instances using Cargo (cargo-base) Plugin. Following is my code.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.4'
    }
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'war'
apply plugin: 'cargo-base'

group = 'com.example.project'
version = '2.7-SNAPSHOT'

description = """demoproject"""

sourceCompatibility = 1.5
targetCompatibility = 1.5

repositories {
    maven {
        url 'http://repo.maven.apache.org/maven2'
    }
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile group: 'commons-configuration', name: 'commons-configuration', version: '1.4'
    compile group: 'commons-discovery', name: 'commons-discovery', version: '0.2'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.3'
    compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
    compile group: 'org.apache.commons', name: 'commons-math', version: '2.0'
    compile group: 'commons-validator', name: 'commons-validator', version: '1.1.4'
    compile group: 'org.apache.commons', name: 'commons-vfs2', version: '2.0'
    compile group: 'log4j', name: 'log4j', version: '1.2.14'
    compile group: 'struts', name: 'struts', version: '1.2.9'
    providedCompile group: 'javax.servlet', name: 'servlet-api', version: '2.4'
    providedCompile group: 'javax.servlet', name: 'jsp-api', version: '2.0'
}

class RemoteContainer {
    String name
    String hostname
    Integer port
    String username
    String password
    String containerId
}

def remoteContainers = [new RemoteContainer(name: 'development', hostname: '10.10.11.25',
        port: 8080, username: 'admin', password: '', containerId: 'tomcat7x'),
        new RemoteContainer(name: 'staging', hostname: '10.10.11.25',
                port: 8181, username: 'admin', password: 'admin', containerId: 'tomcat6x')]

remoteContainers.each { config ->
    task "deployRemote${config.name.capitalize()}"(
            type: org.gradle.api.plugins.cargo.tasks.remote.CargoDeployRemote
    ) {
        description = "Deploys WAR to remote Tomcat '${config.name}'."
        containerId = config.containerId
        hostname = config.hostname
        port = config.port
        username = config.username
        password = config.password
    }
}

task deployToAllRemoteTomcats {
    dependsOn remoteContainers.collect { "deployRemote${it.name.capitalize()}" }
    description = 'Deploys to all remote Tomcat containers.'
    group = 'deployment'
}

But I was getting following exception:

Execution failed for task ':deployRemoteDevelopment'.
> org.codehaus.cargo.container.ContainerException: The [cargo.remote.username] and [cargo.remote.password] properties are mandatory and need to be defined in your configuration.

After investigation I found out that error was due to following line of code

new RemoteContainer(name: 'development', hostname: '10.10.11.25',
        port: 8080, username: 'admin', password: '', containerId: 'tomcat7x'

i.e. cargo plugin doesn't allow us to use empty password, which is a valid password of my tomcat server. Is this intentional behavior or a bug?

bmuschko commented 10 years ago

This exception is thrown from Cargo. There's nothing I can do about in this plugin. Please address this issue on the Cargo user mailing list. They might fix it for you.