Enhance war overlay support through real dependencies

(Davide Cavestro) #1

I’d like some support to compose war artifacts based on dependencies between wars (gradle projects/external libraries) with proper management for provided deps transitivity. It would be very good for customization support and modularization. There is a dedicated issue that lays down as a minor priority RFE since feb 2010… it’s right as long as it has only 4 votes http://issues.gradle.org/browse/GRADLE-811. I also opened a dedicated thread on the user mailing list: http://gradle.1045684.n5.nabble.com/War-plugin-evolution-and-overlays-td4864964.html

It also hangs. I guess in the meantime many people is struggling with ugly hacks in order to survive. I write here in order to spread the verb… and see if other people have this need, too

(Joe McCall) #2

I wanted to share my solution here for others searching for this behavior.

After applying the war plugin, I added the following code to emulate the war overlay behavior:

apply plugin: 'war'
  configurations {
  dependencies {
    warOverlay 'org.jasig.cas:cas-server-webapp:3.5.2@war'
  war << {
    // unpack all the war files into the temp directory for this task
    configurations.warOverlay.each {
        ant.unwar src: it, dest: temporaryDir
      // update the war file, but when a duplicate file is found preserve the original
    ant.war basedir: temporaryDir, destfile: archivePath, update: true, duplicate: 'preserve'

As far as I can tell that does the same thing as the maven war overlay plugin. I may refactor this into a gradle-war-overlay-plugin if enough people are interested.

(Dmitriy Kopylenko) #3

A packaged plugin would be very handy!

(Mader Levap) #4

Final answer and tip: if you need to use files from other project (not maven repo), you have to get through a little more hoops: http://forums.gradle.org/gradle/topics/getting_compiled_war_from_subproject_in_dependencies_of_main_project_not_files_generated_result?rfm=1