This article covers a Hippo CMS version 7.7. There's an updated version available that covers our most recent release.

Import a project into Eclipse 

Once you have set up and built your project, you probably want to use your IDE to edit the source files. This document explains the steps involved in setting up Eclipse for this purpose.

Using m2eclipse

The easiest way by far to do this is to use the m2eclipse plugin for Eclipse. We recommend the use of this Eclipse plugin for all Hippo projects and have a dedicated page explaining some of its options and usages.

Once you have installed the m2eclipse plugin do the following to import your project:

Go to menu File > Import..., expand folder Maven and choose Existing Maven Projects.

 

http://cdn.onehippo.com/binaries/ninecolumn/content/gallery/connect/library/import_dialog3.png

Choose Next.

Browse to the root directory of your project.

 

http://cdn.onehippo.com/binaries/ninecolumn/content/gallery/connect/library/import_dialog2.png

Press Finish. The project will now be imported.

Using the Maven Eclipse Plugin

Alternatively you can use the Maven Eclipse Plugin to generate the Eclipse IDE files for your project. Note that this method requires a few more steps and has some drawbacks compared to using m2eclipse.

Configuring your workspace

In order to work with Maven projects inside Eclipse you need to tell Eclipse how to resolve the location of the artifacts defined within those projects. This is done by defining a special classpath variable inside Eclipse called M2_REPO that points to your local Maven repository.

Open the preferences window by going to menu Window > Preferences. Browse to pane Java > Build Path > Classpath Variables and click New...

 

http://cdn.onehippo.com/binaries/ninecolumn/content/gallery/connect/library/classpath_variables_dialog.png

Enter the variable name M2_REPO, enter the path to your local Maven repository, then click OK.

Generating the Eclipse project files

To generate the Eclipse project files open a terminal and change directories to the root directory of you project. Here issue the following command.

mvn [-o] eclipse:eclipse

This will generate the Eclipse project files using the maven eclipse plugin.

Because an attempt will be made to download the sources and javadocs of all dependencies, this step can take quite a long time. If you don't need these you can use the '-o' (work offline) flag to make the build a lot faster.

Importing the project into Eclipse

Now you are ready to import your project into Eclipse. In Eclipse go to menu File > Import..., expand folder General and choose Existing Projects into Workspace.

 

http://cdn.onehippo.com/binaries/ninecolumn/content/gallery/connect/library/import_dialog.png

Choose Next.

Now select the root directory of your project.

 

http://cdn.onehippo.com/binaries/ninecolumn/content/gallery/connect/library/import_dialog2.png

Press Finish. The project will now be imported.

Problems and how to fix

If you are using Eclipse together with m2eclipse on Windows, you may see errors on the pom.xml's of your created project that say:

Description Resource Path Location Type

Plugin execution not covered by lifecycle configuration:
com.googlecode.mavenfilesync:maven-filesync-plugin:1.0.0:generate
(execution: default, phase: initialize) pom.xml /myhippoproject-cms
line 5 Maven Project Build Lifecycle Mapping Problem 

You can fix this as follows:

  1. open the 'Problems' view: 'Window' -> 'Show View' -> 'Problems'
  2. right-click on one of the red errors that say 'Plugin execution not covered by lifecycle configuration: com.googlecode.mavenfilesync:maven-filesync-plugin:1.0.0:generate (execution: default, phase: initialize)'
  3. from the menu, choose 'Quick Fix'
  4. in the Quick Fix dialog, select the fix 'Permanently mark goal generate in pom.xml as ignored in Eclipse build' and click 'Finish'. Select 'OK' in the next dialog to apply the fix to the 'cms' or 'site' pom. Do not use the root pom here.
  5. Repeat steps 2-4 for the other, identical error
  6. Eclipse will now show two new red errors: 'Projct configuration is not up-to-date with pom.xml. Run project configuration update'. Right-click on one of these errors and choose 'Quick Fix' again.
  7. The only suggested quick fix is 'Update project configuration'. Select all resources and click 'Finish'.

The above steps actually add the following to the <build> section of the files 'site/pom.xml' and 'cms/pom.xml':

<pluginManagement>
  <plugins>
    <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>com.googlecode.mavenfilesync</groupId>
                <artifactId>maven-filesync-plugin</artifactId>
                <versionRange>[1.0.0,)</versionRange>
                <goals>
                  <goal>generate</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <ignore></ignore>
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>