views:

738

answers:

2

I want to import existing maven project into eclipse. I found 2 ways to do it, one is through running from command line mvn eclipse:eclipseand another is to install maven eclipse plugin from eclipse. What is the difference between the both and which one is preferable?
If I install maven eclipse plugin through the eclipse menu Help -> Install New Software, do I still need to modify my pom.xml to include the maven eclipse plugin in the plugins section?

+2  A: 

I find the m2eclipse plugin to be more useful. This provides nice tools like the POM editor and creating a Maven project from within Eclipse.

Taylor Leese
Is using the m2elcipse plugin the same as using mvn eclipse:eclipse?
Harsha
No, they are different. I never found the Maven eclipse:eclipse goal to be of much use. The eclipse goal is only useful if you have a development environment outside of Eclipse and you want to create an Eclipse project for it. If you just want to start a new project using Maven then use the m2eclipse plugin.
Taylor Leese
In my case I have a java project which was created using IDEA. Now I need to port it into Eclipse. So should I be using mvn eclipse:eclipse or the maven eclipse plugin?
Harsha
mvn eclipse:eclipse initially and then once you have the initial project setup then you can use the m2eclipse plugin.
Taylor Leese
Even for importing a new maven project to eclipse, cant I use the File->Import->Maven Projects and select the pom.xml? In this case I dont need to use mvn eclipse:eclipse. Is it right?
Harsha
Yes, you can do it that way as well.
Taylor Leese
**NO**, you don't have to use `eclipse:eclipse` initially, there is no need for that if you have m2eclipse installed. Just **Import... > Maven projects** and forget the maven-eclipse-plugin.
Pascal Thivent
+7  A: 

I want to import existing maven project into eclipse. I found 2 ways to do it, one is through running from command line mvn eclipse:eclipse and another is to install maven eclipse plugin from eclipse. What is the difference between the both and which one is preferable?

The maven-eclipse-plugin is a Maven plugin and has always been there (one of the first plugin available with Maven 1, one of the first plugin migrated to Maven 2). It has been during a long time the only decent way to integrateimport an existing maven project with Eclipse. Actually, it doesn't provide real integration, it just generates the .project and .classpath files (it has also WTP support) from a Maven project. I've used this plugin during years and was very happy with it (and very unsatisfied at this time by Eclipse plugins for Maven like m2eclipse).

The m2eclipse plugin is one of the Eclipse plugins for Maven. It's actually the first and most mature of the projects aimed at integrating Maven within the Eclipse IDE (this has not always been the case, it was not really usable ~2 years ago, see the feedback in Mevenide vs. M2Eclipse, Q for Eclipse/IAM). But, even if I do not use things like creating a Maven project from Eclipse or the POM editor or other fancy wizards, I have to say that this plugin is now totally usable, provides very smooth integration, has nice features... In other words, I finally switched to it :) I'd now recommend it to any user (advanced or beginners).

If you are interested, have a look at this comparison matrix for a more details of the various alternative.

If I install maven eclipse plugin through the eclipse menu Help -> Install New Software, do I still need to modify my pom.xml to include the maven eclipse plugin in the plugins section?

This question is a bit confusing but the answer is no. With the m2eclipse plugin installed, just right-click the package explorer and Import... > Maven projects to import an existing maven project into Eclipse.

Pascal Thivent