I was initially concerned about how much support there was in the two IDEs I’m currently using (Eclipse and IntelliJ IDEA) for Maven. Fortunately they both have very good support (though… not quite perfect yet).
Both IDEs handle managing dependencies through Maven very well. This is probably the most important feature. You’ll never have to go through the hassle of setting up your dependencies within the build script and your IDE. Its defined once only!
Beyond that, both IDEs take slightly different approaches to Maven support.
In Eclipse, the Maven support comes via a 3rd-party plug-in you need to install (isn’t everything an Eclipse plug-in? :-)). The m2eclipse plugin provides a custom editor for managing the Maven POM file. Though I prefer to edit the XML directly I’m sure some will find the custom editor useful when editing their POMs. However, the most valuable part of editor (that IDEA has no counterpart for) is the Dependency Graph. m2eclipse will display a nice “visio-like” display of all the dependencies in your project with arrows indicating the direction of the dependencies. Its an excellent way to see what JARs you’re including in your project and why. I can’t emphasize the value of this feature enough (Here’s a simple example of it). Also, you can find a good overview of m2eclipse here.
What you really need to know is that using m2eclipse on your project tightly integrates Maven with Eclipse. Maven’s POM is the “source of truth” for your project. In other words, your POM is your project file. In fact, I’d recommend that the Eclipse .classpath (and maybe even the .project file) not be checked into a source code control system. Its replaced every time you make a change to your POM. This is important on my current project where I have several different profiles for running on different application servers and/or running with all local or shared resources. All I do is change my active profile and my source folders will be reset accordingly (picking up the correct *.properties files, Spring configuration files, etc).
Furthermore, (its not well documented, but…) m2eclipse will create source files for all your “resource” folders, but… it will ignore all the contents in them!. Instead, it invokes Maven’s “process-resources” lifecycle goal whenever you do a clean build or modify a resource. Your Eclipse build will always need to invoke some Maven goal to get your resources copied to the output directly (see this posting).
The downside of m2eclipse is that running Maven, changing the profile and other options are buried deep in the Eclipse Preferences and Project Properties screens. Toggling between profiles (which is something I need to do semi-frequently) is a pain. Furthermore, running specific goals needs to be managed through the “Run Configuration” and “Run History” screens.
Changing profiles and running goals is pain partially because IntelliJ’s IDEA does this so well. IDEA gives you a nice pane (tool window?) where you can enable/disable any profile detected in the project (via a list of profile checkboxes) and select/run any goal or task in the project. Its really handy. Also, IDEA’s POM editor is excellent. It doesn’t provide a fancy UI like Eclipse, but the POM XML editor is very smart (in keeping with IDEA’s general philosophy of “smart” text editors over UIs). But, where IDEA makes changing profiles really easy, it doesn’t actually support them that well. After reporting it as a bug to JetBrains, its obvious from their response that they have a different approach.
As I said before, both IDEs use Maven’s dependency listing as the source for your project’s classpath. However, where m2eclipse/eclipse treats the entire POM as the definition for the IDEs project, IDEA considers its project files as the main “source of truth”. IDEAs perspective is to import a POMs settings into the IDEA project.
With profiles, this becomes important. In Eclipse, when you change profiles the project gets “reset” to match the profile. But in IntelliJ, you “re-import” the project and IDEA will only add any new source folders and leave any existing ones (that are now invalid for the profile) still in place! Since JetBrains views the IDEA project as the master, they don’t know where the folders not in the current profile are there because of a previous profile or because you customized the project yourself. This makes dealing with profiles a pain because you constantly have to go into your project’s settings and correct the source folders to match the profile. This is compounded by the fact that IDEA assumes to own the output directories and doesn’t always detect that Maven has made changes to resource files. Depending on the situation, IDEA can get out of synch with the files underneath.
Neither the deficiencies in m2eclipse or IDEA is enough to really get in the way. I just really want to be able to have my cake and eat it too! If IDEA would treat the POM as the “single source of truth” for the project and have a Dependency Graph view I’d be thrilled! If m2eclipse would provide a “Maven View” similar to the “Ant View” Eclipse already has that included the profile switching, again I’d be happy as a clam. However, as it stands, no matter which IDE I use for Maven, I feel I’m missing something…