Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Have multiple Dynamic web projects contribute to a single war file?

I am in a situation where I basically want to be able to have a web project in Eclipse where the WebContents folder is merged from multiple projects instead of only a single dynamic web project.

If I have "a.jsp" in project A, and "b.jsp" in project B, I would like to end up with a single web application in the web container where "a.jsp" and "b.jsp" sit next to each other in the same folder. It would be perfect if all files, not just the jsp-files, could be merged like this.

This is to be able to have a core version of our application but being able to handle customer specific changes easily.

I know I can do this with suitable ant magic, but we want to have something that works well for our current Eclipse based development process. We will use JSR-330 dependency injection on Java classes, and essentially I'd like something along the lines of dependency injection but just for any resource and not just classes.

Can Eclipse do this?

If Eclipse cannot, would an EAR deployment be suitable perhaps? I currently have experience with WAR's only.

like image 671
Thorbjørn Ravn Andersen Avatar asked Jan 07 '10 09:01

Thorbjørn Ravn Andersen


People also ask

What is dynamic Web project in Eclipse?

Dynamic web projects can contain dynamic Java EE resources such as servlets, JSP files, filters, and associated metadata, in addition to static resources such as images and HTML files. Static web projects only contains static resources.


2 Answers

If using Maven is an option, then Maven overlays would be perfect here and it should theoretically be supported by the m2eclipse plugin. But I don't have any experience with that and there might be some issues (see MNGECLIPSE-599) so this would require some testing.

Nevertheless, the comments of MNGECLIPSE-599 are pretty interesting, especially this one:

Any love for this issue? Our entire team has moved to Netbeans for WAR development because of this. We are basically waiting for Servlet 3.0 to solve this issue for us (Servlet 3.0 would effectively negate our need to do overlays in Maven) Our company is big on reducing copy-paste so we use overlays to manage WAR media that must be common in our apps.

The way Java EE 6 would make overlays obsolete is not crystal clear for me (through Web Fragments?) but the fact is that Eclipse's WTP release with Java EE 6 support has been delayed to June 2010. So, until then, you'll need extra tooling (e.g. maven overlays) or should maybe consider switching to NetBeans.

like image 145
Pascal Thivent Avatar answered Oct 05 '22 11:10

Pascal Thivent


I had a similar use case which I successfully resolved by using (as Pascal suggested) Maven. I have a root web project (which also works standalone) and for each client I have a separate web project which is configured to overlay with the root web project. Furthermore, since each client has several environments I created a maven profile for each environment (test, prod, local, ...). I documented this a bit so if ever you are interested I don't mind mailing you the doc.

like image 32
Stijn Geukens Avatar answered Oct 05 '22 10:10

Stijn Geukens