Hello, this is follow-up for question about war overlays. I finally found time to wrestle with it and found something that should work… of course it doesn’t. I have two projects (well, prototypes): bookman-common and bookman-front-web. Both are WARed, but bookman-common.war is intended to be intermediate war that is underlayed for bookman-front-web.war. Below are builds:
build.gradle for bookman-common:
apply plugin: 'war'
group = 'org.mader.bookman'
version = '0.0.9'
description = 'BookMan: Common data and code.'
// ... dependencies and other
build.gradle for bookman-front-web:
apply plugin: 'war'
group = 'org.mader.bookman'
version = '0.0.9'
description = 'BookMan: frontend project - webpage.'
configurations { warUnderlay }
dependencies {
// our projects, to ensure proper order
compile project(':bookman-common')
warUnderlay 'org.mader.bookman:bookman-common:0.0.9@war'
// ... blah blah whatever other dependencies
}
war << {
// unpack underlays
configurations.warUnderlay.each { ant.unwar src: it, dest: temporaryDir }
// now unwar current project, overwritting anything in underlays
ant.unwar src: archivePath, dest: temporaryDir
// recreate war, now with underlay
ant.war basedir: temporaryDir, destFile: archivePath
}
In settings.gradle are both projects: ‘bookman-common’, ‘bookman-front-web’. There is main gradle build file used to run everything. Trying to run from main gradle builder file results in this:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\devel\workspace\testland\bookman-front-web\build.gradle' line: 46
* What went wrong:
Execution failed for task ':bookman-front-web:war'.
> Could not resolve all dependencies for configuration ':bookman-front-web:warUnderlay'.
> Could not find org.mader.bookman:bookman-common:0.0.9.
Required by:
org.mader.bookman:bookman-front-web:0.0.9
It is like it taunts me.
I suspect line
warUnderlay 'org.mader.bookman:bookman-common:0.0.9@war'
is incorrect, but I have no other idea to how to get generated war from bookman-common subproject. Using
warUnderlay project(':bookman-common')
ends horribly (tons of files lands in bookman-front-web.war in all wrong places, and to add insult to injury some files from bookman-common aren’t present anyway). This is because it gets jars and libraries, not generated war.
Another try:
warUnderlay project(':bookman-common@war')
Just Don’t Work ™.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\devel\workspace\testland\bookman-front-web\build.gradle' line: 18
* What went wrong:
A problem occurred evaluating project ':bookman-front-web'.
> Project with path ':bookman-common@war' could not be found in project ':bookman-front-web'.
So… it is possible at all? How?