Article Figure 1 Figure 2 Listing 1 Listing 2
Listing 3 Listing 4 Listing 5 Sidebar 1 Sidebar 2 aug2006.tar

Maven Configuration for Eclipse 3.1

It's likely that most software developers will be using an IDE, such as Eclipse or IntelliJ IDEA, and while using Maven from a command line is easy, switching between the two is inconvenient. Fortunately, plug-ins are available that integrate Maven with these IDEs (Eclipse: http://m2eclipse.codehaus.org/ and IntelliJ IDEA: http://plugins.intellij.net/plugins/).

As an example, to integrate Maven and Eclipse, the best procedure is:

  • Before starting Eclipse, run Maven from a command line to create the standard directory structure.
  • Run the eclipse:eclipse goal to generate the Eclipse project files. Note that the eclipse:eclipse goal in some Maven version 2 distributions doesn't work. Adding the org.apache.maven.plugins plug-in as shown in Listing 4 will ensure the latest version of the goal is used.
  • Import the project into Eclipse with the usual File | Import menu option.
  • Set the M2_REPO classpath variable to point to the local Maven repository. If Eclipse reports any dependency conflicts, right-click on the project and from the context menu select Maven2 | Update Source Folders.
  • Right-click on the project and, from the context menu, select Maven2/enable.

Once the project has been imported and enabled, Maven goals can be set up and executed as external tools.