Question: In our company, we have a number different modules constructed as separate wars. 
Each client can pick and choose module he wishes to buy.
Since all modules share same session, security context etc, it makes sense to merge them into a single war. 

Is it possible to automate this process? For example, it should merge web.xml, calculate each wars dependencies, copy files like .jsp and .class etc. By the way, we are using Maven, but were not able to find a solution to this problem.

Answer: 
Granted the risks mentioned by djna and ChssPly76, you may be able to achieve this by using overlays with the [Maven WAR plugin](http://maven.apache.org/plugins/maven-war-plugin/overlays.html). This will require you to separate out servlet mappings to ensure you don't have any URL collisions and the like, but it might do the trick.

Basically, you create a module with multiple WAR dependencies and use the plugin to merge them into a new one.
Generally speaking - no, it's not possible. What if you have duplicate JSP names? Servlet names / mappings? Same context listeners loading with different parameters (common if you're using Spring / Struts / etc...)? You get the point. 

In your particular case it may or may not be possible depending on your specific circumstances. Extracting war and copying JSP / classes / libraries over is easy; merging web.xml is a bit more complex as you have to maintain the element order - it may be easier to manually define a "merged" web.xml.