Deploy EAR exploded


(Christoph Baumann) #1

When I deploy an EAR (that just contains WARs) to my local application server, I would like to skip the war tasks and deploy everything in exploded form.

I have managed to deploy the EAR in exploded form, but the war tasks are still running and thus I do not gain the speed-up I intendend.

task deploy(type: Sync) {
    with ear
    into 'C:/path/to/server/deployments/'
    exclude '**/*.war'
    def deps = configurations.deploy.getAllDependencies().withType(ProjectDependency)
    deps.each { dep -> 
        into(dep.dependencyProject.war.archiveName) {
            with dep.dependencyProject.war 
        }
    }
}

What is the best way to not trigger the war tasks?


(Lance Java) #2
tasks.withType(War).all { it.enabled = false }

(Christoph Baumann) #3

Hi Lance. Thanks for the quick answer. Of course that would disable the war tasks. Unfortunately your approach would disable the war task completely. And I still need them to work in other cases. I just want to skip them, when i run the deploy task.


(Lance Java) #4
gradle.taskGraph.whenReady { TaskExecutionGraph g ->
   if (g.hasTask(deploy)) {
      tasks.withType(War).all { it.enabled = false }
   }
}

(Mark Vieira) #5

A slightly more concise alternative to @Lance_Java’s example.

tasks.withType(War) {
  onlyIf { !gradle.taskGraph.hasTask(deploy) }
}

(Christoph Baumann) #6

Yep, that solves my problem. Thank you guys!