3

I found that the ear plugin overrides the war plugin and prevents the war task being called. I got around it by calling it directly.

Is this remotely sensible or should I give up and move to a multi-project setup in eclipse and gradle?

ear {
    doFirst {
        println " - force build war..."
        tasks.war.execute()
    }

    from("$destinationDir") {
        exclude('nz')
        rename ('TrialApp(.*)(.war)', 'TrialApp.war')
        include 'TrialApp*.war'
        into('')
    }
    deploymentDescriptor {  
                applicationName = "trialapp"
                initializeInOrder = true
                displayName = "Trial App"  
                description = "Trial App EAR for Gradle documentation"
                libraryDirectory = "WEB-INF/lib"  
                webModule("TrialApp.war", "TrialApp")  
    }
}
Andrew Sumner
  • 793
  • 2
  • 12
  • 29
  • 1
    this question is, for me, far more useful than any gradle documention I've yet come across. My two cents. – Thufir Aug 23 '17 at 03:05

1 Answers1

5

The Ear plugin doesn't override the War plugin, it simply doesn't execute the war task by default. Anyway, what you are trying to do is certainly possible. Instead of adding a dependency to a separate war project (as is described in the documentation you can simply depend on the war task itself.

apply plugin: 'war'
apply plugin: 'ear'

dependencies {
    deploy files(war)
}   
Mark Vieira
  • 13,198
  • 4
  • 46
  • 39