bmuschko / gradle-cargo-plugin

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

Deployable doesn't exist #161

Closed jeusdi closed 7 years ago

jeusdi commented 7 years ago

I'm getting this message when I perform my deploy task:

Execution failed for task ':deployDevWildfly10'. Deployable ...\commty\build\libs\commty-dev-a2e81e2-dirty.war does not exist

As you can see it's trying to pick the artifact from build\libs.

Nevertheless, :deployDevWildfly10 is a custom made CargoDeployRemote task type:

remoteContainers.each { config ->
    task "deployDev${config.name.capitalize()}"(type: com.bmuschko.gradle.cargo.tasks.remote.CargoDeployRemote) {
        description = "Deploys WAR to remote Web Application Server: '${config.name}'."
        containerId = config.container
        hostname = config.hostname
        port = config.port
        username = config.username
        password = config.password
        context = "webapi"
        dependsOn = [createDevelopmentWar]
    }
}

As you can see it depends on createDevelopmentWar (a custom made War task type):

task createDevelopmentWar(type: War, dependsOn: classes) {
    archiveName "commty-dev-${versioning.info.display}.war"
    destinationDir = file("$buildDir/dist")
    webInf {
        from('scopes') {
            include 'configuration.development.properties'
            rename('configuration.development.properties', 'scope.properties')
            into('classes/')
        }
    }
}

As you can see, I set destinationDir to file("$buildDir/dist"). So, the artifact is going to be generated in build\dist instead of in build\libs. Is there anyway to change this behaviour?

It works if I delete archiveName and destinationDir parameters from custom made war task:

task createDevelopmentWar(type: War, dependsOn: classes) {
    webInf {
        from('scopes') {
            include 'configuration.development.properties'
            rename('configuration.development.properties', 'scope.properties')
            into('classes/')
        }
    }
}
bmuschko commented 7 years ago

By default the base plugin already assigns a specific WAR file. You can reconfigure the task and assign a different "deployable".

remoteContainers.each { config ->
    task "deployDev${config.name.capitalize()}"(type: com.bmuschko.gradle.cargo.tasks.remote.CargoDeployRemote) {
        ...
        dependsOn = [createDevelopmentWar]
        deployables = [new com.bmuschko.gradle.cargo.convention.Deployable(file: createDevelopmentWar.archivePath)]
    }
}

The key to understanding what and how you can do it is to check the Javadocs for the task type. Please make sure to explore before opening an issue.