M2Eclipse (m2e) Support for Maven Eclipse Plugin Projects

If you have a Maven based Eclipse project that you generated using mvn eclipse:eclipse, you’ll notice you won’t be able to use M2Eclipse (m2e) with it. If you look at the Eclipse .project file, you’ll see this comment.

NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.

Here’s how you can convert your Maven Eclipse Plugin project to m2e. First add the M2Eclipse builder under the buildSpec tag, and the M2Eclipse nature under the natures tag, both inside the .project file.

...
<buildCommand>
  <name>org.eclipse.m2e.core.maven2Builder</name>
</buildCommand>
...
<nature>org.eclipse.m2e.core.maven2Nature</nature>

Next step is to replace all the M2_REPO libraries in the .classpath file with the M2Eclipse classpath container.

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>

Refresh your Eclipse project. Right click on the project in Project Explorer View and you should now see the Maven option.


2 Comments

  1. panda says:

    Nice One. Just to be more precise

    Remove all tag which having path value ‘M2_REPO” and add this

  2. Abu al-Sous says:

    Right on; exactly what I needed

    Many thanks, you have saved lots of man hours


Leave a Reply

Your email address will not be published. Required fields are marked *