tags:

views:

113

answers:

5

Many IDEs supports to import maven projects directly, but maven has a maven-eclipse-plugin, when you run :

mvn eclipse:eclipse

It will generate eclipse project settings ,then you can import as generic eclipse project.

Which one is better?

I prefer importing directly using m2eclipse, as my IDE is Spring Source Suite (eclipse 3.5 shiped with WTP 3.1 and m2eclipse).

I am not sure if m2eclipse import a maven project,internally using "maven-eclipse-plugin" to convert into an eclipse project.

Does maven-eclipse-plugin support WTP 3.1 project settings ? From my experiments, maven-eclipse-plugin can't generate WTP 3 above compatible settings.

+2  A: 

We use the mvn eclipse:eclipse method and it works fine, but I believe the preferred way would be to use the m2eclipse plugin, as it appears to make this integration very easy. I haven't used it myself though since we use RAD which is based on an older version of Eclipse which doesn't support that plugin.

Robin
Beat me to it. I have used the plugin, and although it's not without its flaws, the latest version seems to have fixed most of them. It has auto-complete and gui support when editing the pom, and some nice tools for viewing the dependency graph.
gregcase
+2  A: 

I prefer the

mvn eclipse:eclipse

method myself. I've used the m2eclipse plugin but I had a couple of issues with it in regards to recognizing projects that were already created, and it also fills my context menu in eclipse with a lot more items. I prefer to keep my IDE with as few plugins as possible and prefer to work with maven from the command line. This also helps as on my team, we don't have a standard IDE so we don't put IDE generated artifacts in source control. Knowing that everything can be built from the command line very easily helps with the IDE independence as well as continuous integration.

Casey
But,can "mvn eclipse:eclipse" generate WTP 3 above compatible settings ? I generate wtp 1.5 settings with "mvn eclipse:eclipse" without problems, when I import it into eclipse 3.5, lots of errors.
ZZcat
You would have to add the requisite information to the pom as @pascal mentioned in his answer.
Casey
A: 

I can telly you my experience with JetBrains IDEA.

It is better to use the Maven importing feature from IDEA instead of maven because the IDE knows better the format of the project you have to create.

As an example, I don't know if mvn:idea creates projects files for IDEA 9.

volothamp
+1  A: 

(Usually) Built in IDE plugins are better then the generic ones provided by the product, since they know their own format better, can access built in functions used by the IDE itself, and stay updated.

Here I would highly recommend the built in Eclipse plugin.

TheLQ
+1  A: 

Which one is better?

They are different. The maven-eclipse-plugin is very light since it doesn't do anything once the project has been imported in Eclipse but doesn't provide real integration: no bidirectional support, no pom.xml editor, no fancy wizards, no module creation from Eclipse... I personally don't care that much of these features. However, there is one thing that I really need in many projects: support of resources filtering inside the IDE. m2eclipse does that since it embeds Maven.

I am not sure if m2eclipse import a maven project, internally using "maven-eclipse-plugin" to convert into an eclipse project.

No it doesn't, it really add a new Project Nature.

Does maven-eclipse-plugin support WTP 3.1 project settings ? From my experiments, maven-eclipse-plugin can't generate WTP 3 above compatible settings.

The plugin can create WTP R7, 1.0, 1.5 and 2.0 configuration files. WTP 2.0 configuration files are compatible with WTP 3.0 (the structure didn't change).

You can declare the wtpversion parameter on the command line or in the plugin configuration. Below an example:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.8</version>
    <configuration>
      <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
      <wtpmanifest>true</wtpmanifest>
      <wtpapplicationxml>true</wtpapplicationxml>
      <wtpversion>2.0</wtpversion>
      <manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
    </configuration>
  </plugin>
Pascal Thivent
Thanks, Pascal, you answers are always that great!
ZZcat