Maven: How to use with Eclipse

Approach Using M2Eclipse Plugin

We recommend using the M2Eclipse Plugin for Maven.  First you will want to have the most current versions available of the following:

First, install Eclipse Classic.  Next,

Install Eclipse XML Editors and Tools

Go to Help > Install New Software:

Picture21.png

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

Picture22.png

Install the M2Eclipse Plugin

Use the same facility to add the M2Eclipse tools.  Click the Add. . .  button and enter the M2Eclipse update site URL:  http://m2eclipse.sonatype.org/update/

Picture23.png

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:

Picture12.png

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

Picture13.png

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

Picture14.png

Congratulations your project has been creaed:

Picture16.png

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, do the following steps:

Picture18.png

Right-click on your pom > Maven > Downlaod 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 e.g. web/target directory in your package explorer, and click Properties:

Picture17.png

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.

Picture24.png