Maven: Using with Eclipse

We recommend using the M2Eclipse Plugin for Maven.

Approach using M2Eclipse plugin

First you will want to have the most current versions available of the following:

  • Eclipse Classic version of the Eclipse IDE:
  • Eclipse XML Editors and Tools
  • M2Eclipse Plugin

First, install Eclipse Classic.

Install Eclipse XML editors and tools

  1. Go to Help > Install New Software:

  2. Select the Galileo update site and select the Eclipse XML Editors and Tools:

Install the M2Eclipse Plugin

  1. Use the same facility to add the M2Eclipse tools. Click Add and enter the M2Eclipse update site URL:

  2. Select the first group, to include all of "Maven Integration". When this completes successfully, your IDE should be good to go. It will restart several times in the above process.

Project Setup

From an empty or existing workspace, choose File > Import or right click on the Package Explorer pane and select Import. Select to import Maven Projects:

M2Eclipse will detect all the pom files and generate the project structure.  Create a New. . . Java working set from this:

Click on the Advanced options and add a template name to tie each maven module to your project, for example, Acme-[artifactId].

Congratulations your project has been created:

Now when you build Eclipse will use the Maven compile configuration.

Where are my sources?

Sources are stored in Maven source jars.

To download and link these up in your IDE, follow these steps:

  • Right-click on your pom > Maven > Download Sources.

This should pull the dependency sources and link them up. Try by pulling up a Jive class, such as LoginAction (cmd+shift+T) and validate the source is there.

And what about my .ftls and other war file sources?

If you have downloaded a source build, you can perform the above sets and create a new working set that references those source files. However, the simplest approach is to include your war target directories in the project configuration. The good news is that this will happen by default, unless you choose to explicitly hide the target directories. The bad news is you'll see multiple entries for files such as struts-community-custom.xml when you do a resource search (cmd+shift-R).

If you want to go ahead and hide the target directories from an index search, right-click on the web/target directory in your package explorer, and click Properties:

If you check the Derived checkbox, it will no longer appear in your searches.

Maven-only alternative method

It is possible to use Maven with Eclipse without using the M2Eclipse tool.

  • From the root of your project run the following command:
    mvn eclipse:clean eclipse:eclipse -DdownloadSources=true

This will refresh your existing eclipse project files and link up your sources, so that all SBS sources are indexed and will link up in the debugger.

Then from a fresh workspace you import the root directory as an existing project.