War Overlaying - Opinions


(Daniel Wilmer) #1

Hi everybody,

I am asking for a short opinion regarding the following war overlaying solutions.

  • Which of the following possible solutions should be preferred?
  • Or is there an even better/faster/IDE-friendlier solution that I have not seen yet?

1. A slightly hacky solution, but it works well:

configurations {
    warOverlay {
        transitive = false
    }
    compile.extendsFrom(warOverlay)
}

dependencies {
    warOverlay project(':war1')
    warOverlay project(':war2')
}

war {
    duplicatesStrategy = 'exclude'
    configurations.warOverlay.each {
        from zipTree(it.path.replace(".jar", ".war"))
    }
}

2. The maybe more correct™ solution:

The modules (war1 and war2) must expose their war artifact:

configurations {
    thewar
}

artifacts {
    thewar tasks.war
}

The final wapapp itself:

configurations {
    warOverlay {
        transitive = false
    }
}

dependencies {
    compile project(':war1')
    compile project(':war2')
    warOverlay project(path:':war1', configuration: 'thewar')
    warOverlay project(path:':war2', configuration: 'thewar')
}

war {
    duplicatesStrategy = 'exclude'
    configurations.warOverlay.filter({it.name.endsWith(".war")}).each {
        from zipTree(it)
    }
}

3. Using a third party plugin

I don’t really want to depend on a third party plugin if it is not absolutely necessary.


Multi Project build with source override options