Subproject compiles as jar into \web-inf\lib of main project war, but I want to put code directly in war

Java 7, Gradle 1.11, Eclipse Kepler

I have yet another prototype with two projects. First one is war project (lets name it main-project) and second is sub-project (jar). Idea is to reuse sub-project in many various projects, providing common classes and beans like language handling, configuration etc. Currently sub-project is compiled as sub-project.jar that is put in \WEB-INF\lib of main-project.war.

And here lies problem. Sub-project has beans. CDI does not like that these beans are in jar and cannot resolve them. I have to have compiled files directly in main war directories, like it was in main-project, not in sub-project.

Both projects has plugins java, maven, eclipse, but main project has additionally war plugin.

main gradle file:

defaultTasks 'clean', 'build', 'deploy'
  allprojects {
}
  subprojects {
  apply plugin: 'java'
  apply plugin: 'maven'
  apply plugin: 'eclipse'
    sourceCompatibility = 1.7
  targetCompatibility = 1.7
...
}

build.gradle for main-project:

apply plugin: 'war'
dependencies {
  compile project(':sub-project')
}

I do not want separate sub-project.war. I want sub-project compiled classes and other files to land in main-project.war: code to WEB-INF\classes, things in webapp directly to root of war - exactly like it was in main-project. How I can do that?

Gradle doesn’t ship with built-in support for war overlays, and configuring this manually will take some effort and know-how. Hence I’d first try to find a third-party war overlay plugin. A quick Google search turned up https://github.com/scalding/gradle-waroverlay-plugin, but perhaps there are others.

Oh, I did not know it has its own name - war overlay. Thanks for the tip and link. Will check this and other plugins.

Oh, I did not know it has its own name - war overlay. Thanks for the tip and link. Will check this and other plugins.