gradle war overlays: IDEA support?

Answered

We have a multi-module project that used a maven build with overlays to build a war from multiple sub-projects.
IDEA handled that fine: I was able to build and deploy from within IDEA without invoking maven.

Now I converted the project to gradle, but maven's overlay feature causes problems, because gradle does not support it and I found no way to emulate it that IDEA understands.

My current solution looks like:

dependencies {
overlay project(path: ':some-web', configuration: 'war')
}

war {
configurations.overlay.files.each {
from(zipTree(it))
}
}

However now I can only ever build with gradle. IDEA does not understand that the content of "some-web" should also go into the final war.

Goodbye to Ctrl-Shift-F9 to quickly compile/package a file :-(

Is there any way I can set up my gradle build, so that IDEA understands what should go into the final war?

2 comments
Comment actions Permalink

You could try the following:

settings.gradle

include 'common', 'web'

common/build.gradle

apply plugin: 'war'

web/build.gradle

apply plugin: 'war'
war {
with project(':common').war
}

 

 

 

 

0
Comment actions Permalink

Unfortunately that just gives an error:

"Could not get unknown property 'war' for project ':common' of type org.gradle.api.Project."

However I found that this works for both IDEA and gradle:

war {
from { project(':common').webAppDir }
}

Yet, it feels wrong to directly reach into the source of another project.

More importantly: It does not work for war overlays from a maven dependency (Some wars must be loaded from our internal maven repo before being overlayed).

0

Please sign in to leave a comment.