Migrating a web project from MyEclipse to Web Tools Project (WTP) 0.7
I recently migrated a web project that was using MyEclipse to using Eclipse WTP. It was actually quite simple. This assumes you have Eclipse 3.1 and WTP 0.7 installed (WTP also requires EMF and GEF to be installed). I started by creating a web project using WTP’s template (create a new “Dynamic Web Project”). Then I inspected the files it created and applied the differences to my existing MyEclipse-based project.
The web project I created with WTP was called “webproject”. So when you see “webproject” in the following files, that is the project name. The project layout looks like this:
In my MyEclipse-created project, “JavaSource” is “src”, and “WebContent” is “WebRoot”.
I opened up Navigator view to get a better of view of the files involved.
Lets look at the .classpath created, parts that need to change are bolded:
Note the “bin” directory that is configured as an output directory. I left that as is. I replaced my entire .classpath file with this version. Most of my jar files are in WEB-INF/lib which WTP automatically adds to classpath, so the references to those jar files were not included in .classpath (you get an error if you do). There were some jar files that are not deployed that I included in .classpath, though.
I took the .project file from the WTP and replaced my MyEclipse .project with it, changing only the project name.
Then I copied over the .wtpmodules file to the root of my project:
I deleted the WebRoot/WEB-INF/classes directory that used to be an output directory. I closed and opened the project, did a Project->Clean which triggered a rebuild of the project. Then I switched to J2EE perspective and configured a Tomcat 5.5 instance for my project, started it up, browsed to URL that it normally is at, and everything worked. The .deployables directory was created automatically and I did not have to create it.
With the MyEclipse project, I was able to set it up such that I could work on the project in Eclipse without MyEclipse installed (just had to use Ant to build deployables). However, I’m not sure that it will work with this setup (Eclipse without WTP), since the classpath doesn’t have the jar files and they are probably not automatically included if WTP is not installed.