I have a web app that I would like to split into three pieces. I noticed it has two completely distinct functionalities, but the core architecture (libs used in presentation layer, Spring container, DAO etc.) is shared.
One piece would be the “master”, with full vertical stack from presentation through DAO, but only for what’s common for all “subprojects”.
The other two modules would be the “subprojects” themselves.
Now the question is: Is it possible to get Maven to treat all 3 pieces (modules?) as one, so that they would be built and most importantly packaged together? I need the final result to be a single war with directory tree similar to:
war
+ WEB-INF
+ classes
+ subproject1
+ subproject2
+ view-shared
+ css
+ ...
+ js
+ ...
+ subproject1
+ myPage.jsp
+ subproject2
+ anotherPage.jsp
You get the idea.
You can do it using the Maven assembly plugin.
Another solution is to have:
commonproject (packagingjar)subproject1(packagingwar) that hascommonas dependency.subproject2(packagingwar) that hascommonas dependency.webproject (packagingwar) that has bothsubproject1andsubproject2as dependencies.When Maven will build the
webproject, it will first unzip bothsubproject1andsubproject2wars in theweb/targetdirectory, and then copy the content of thewebproject itself in thistargetdirectory.This means that if a file exists in
subproject1and inwebprojects, then the file hosted bywebwill erase the one hosted bysubproject1in the final WAR file.You can find more information about Maven WAR overlays.