views:

491

answers:

3

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.

A: 
  • you don't need to change your "eclipse based development process" to use ant. Just register an Ant builder (right click project > Properties > Builders) and integrate the ant script with your eclipse process
  • you can use maven's multi-module options. (The maven plugin for eclipse is very good as well)
  • use can also use FileSync - not industry-standard but pretty powerful. It's used for developing on localhost, of course.

Here are a few tips for using FileSync:

  • setup which files/file patterns/dirs to copy to a target directory (Tomcat's webapps/application in your case). So as soon as you press "save", the files are copied.
  • make all absolute paths in the FileSync.xxxx.prefs relative by introducing a Linked Resource (preferences > workspace > linked resources), and using the link resource variable in the prefs file (lets call it WEBAPP_HOME)
  • commit the FileSync.xxxx.prefs file
  • tell each developer on the team to configure the WEBAPP_HOME variable. Thus the setup will not be valid for only one machine, but for each machine in the team.
Bozho
Do you have experience with an ant builder when doing web application development? We currently use Tomcat, but for JSR-330 reasons we consider migrating to Glassfish. I am especially interested in the turnaround time - press Ctrl-S, and reload in browser.
Thorbjørn Ravn Andersen
I have experience with maven and with the newly-added option - FileSync.I use maven for creating a build, and FileSync for CTRL + S stuff. It's pretty powerful - you just configure it to move files from each project to a common target dir.
Bozho
A: 

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 JEE 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.

Pascal Thivent
maven is not an option unless we absolutely, unavoidably have to. We are not tempted by the maven way of life :)The reason for JEE6 is that we would like to push the web service stack, dependency injections and JSF 2.0 into the container instead of deploying suitable implementations inside the WAR. From my investigations today I do not think the time is right yet for that.
Thorbjørn Ravn Andersen
Thanks for the mentioning of Servlet 3.0 to resolve something. I'll look into it.
Thorbjørn Ravn Andersen
A: 

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.

TheStijn