I have a parent project and multiple child projects. I want a war to be generated with class files from a couple of child projects and jars in lib from a couple of child projects.How to achieve this?
I think you have three options here:
- You set up a dedicated subproject whose only purpose it is to generate the WAR file by applying the
warplugin. Dependencies to other subprojects are declared via project dependencies which the plugin resolves at runtime and adds them to the
WEB-INF/libdirectory in the generated WAR file.
- You create a task of type
Warin one of the subprojects that should be responsible for the WAR file creation. Establish project dependencies as described in 1.
- Make the root project responsible for creating the WAR file. You’d set up a task of type
Warin the root project’s
build.gradleand then ask for the runtime classpath of all subproject that should be included.
Option 1. is probably the easiest to achieve your goal.
I want the class files of sub-projects in war’s classes folder rather than as jar in war’s luv folder. Please advise.
I can’t think of any compelling reason for wanting to do but you can get the compiled class files from the
main source set of each subproject via
There compelling reason is that some sub-projects are not really libraries and we don’t want them to be jars in war’s lib folder.
Can you please elaborate your solution?