Migrating from m2eclipse to m2e
Since Indigo, the Maven Eclipse plugin formerly known as m2eclipse became part of Eclipse release (at least in the pure Java release). The name of the plugin also changed from m2eclipse to m2e. This was not the sole change, however:
- The number of tabs on the POM has shrinked drastically, and the features as well. This will probably be the subject of a later post since I feel quite cheated by the upgrade.
- The POM configuration has been more integrated with Eclipse build (which can cause unwanted side-effects as I described in my last article).
More importantly, projects that began with m2eclipse can be built in Indigo but no contextual Maven menu is accessible on the project itself (though a contextual menu is available on the POM).
In order to migrate flawlessly and have our contextual menu back, some actions are necessary. They are gruesome because it involves updating by hand Eclipse configuration file.
Warning: at this point, you have the choice to stop reading. If you decide to continue and use the process described below, it’s at your own risk!
The Maven plugin recognizes a project as a Maven one based the .project Eclipse proprietary configuration file. To display it, go to the Project Explorer view, click on the scrolling menu at the top right and choose Customize View. You have to uncheck *.resources: along the .project file , you should see a .classpath file as well as a .settings folder.
- In the .project:
- Replace org.maven.ide.eclipse.maven2Builder by org.eclipse.m2e.core.maven2Builder in the buildSpec section
- Replace org.maven.ide.eclipse.maven2Nature by org.eclipse.m2e.core.maven2Nature in the natures section
- In the .classpath, replace org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER by org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
- Finally, in the .settings folder, rename the org.maven.ide.eclipse.prefs file to org.eclipse.m2e.core.prefs. Contents should be left unchanged.
Now, the contextual menu should appear and work accordingly.
Remember, this is a big hack you should only use with the right parachute (at least a source control management system) since it will hurt you plenty if it fails. For me, it has always worked… yet.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
André Pankraz replied on Tue, 2011/09/27 - 4:15am
what is not "at your own risk" with eclipses maven-support (or subversion, WTP etc.) - no disclaimers necessary for this stuff ;)
sometimes i wonder why i still use it every day...
Dave Alkire replied on Tue, 2011/09/27 - 12:51pm
- Were you using the latest Eclipse upgrade? It looks like Indigo SR1 was supposed to come out last Fri, 9/23.
- Do you know if Eclipse has a ticket for this issue? I did a cursory search in their Bugzilla system; I didn't see anything that looks like what you describe but I wasn't very thorough. Do you have a Bug#/URL? If not, have you tried to create one yet?
Thanks again.
John J. Franey replied on Tue, 2011/09/27 - 3:35pm
On upgrade to indigo, I merely created a new workspace and imported the projects as maven projects. Import... -> Existng Maven Projects. No touch on eclipse project or settings files. These eclipse files are almost throw away. If eclipse is restarted when these are missing, eclipse is confused about these projects.
I recommend the jboss tools maven configuration plugins. I use them an rarely have a problem importing my projects. Maven plugin has a 'quick fix' feature now that I think the jboss plugins extend. For example, if a seam build error is detected, quick fix knows how to add the seam facet to the project.
Nick Tan replied on Tue, 2011/09/27 - 6:22pm
well, this annoyed me as well at the begainning
but actually you can re-import the maven projects into workspace:
done, that easy, it will update the project nature,settings
Nicolas Frankel replied on Wed, 2011/09/28 - 1:18am
in response to:
Dave Alkire
Hi Dave,
It's Indigo without SR1 and I didn't search for a bug... Too accustomed to be on my own I guess :-)
Kathy Blackmore replied on Tue, 2012/01/10 - 1:39am