Nicolas Frankel is an IT consultant with 10 years experience in Java / JEE environments. He likes his job so much he writes technical articles on his blog and reviews technical books in his spare time. He also tries to find other geeks like him in universities, as a part-time lecturer. Nicolas is a DZone MVB and is not an employee of DZone and has posted 232 posts at DZone. You can read more from them at their website. View Full User Profile

Migrating from m2eclipse to m2e

09.27.2011
| 20373 views |
  • submit to reddit

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.

  1. 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
  2. In the .classpath, replace org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER by org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
  3. 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.

 

From http://blog.frankel.ch/migrating-from-m2eclipse-to-m2e

Published at DZone with permission of Nicolas Frankel, author and DZone MVB.

(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

Thanks Nicolas; this will be very helpful workaround.  I have a couple questions for you though:

- 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

Good topic. I've been using m2 eclipse plugins for a few years. I have long abandoned keeping my maven project in my eclipse workspace. Instead, I have a separate projects directories. I use maven import to pull them in.

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:

  1. delete the project from workspace (note that don,t delete the content)
  2. file -> import -> maven -> browse the maven project from file sys

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

Thanks for the tips. I hope that your hack works for me as well as it had worked for you. I have looking for a way to bring back the contextual menu, and I sure hope this works.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.