Want to show your appreciation? Please to my charity.

Friday, January 20, 2012

Maven and Its Eclipse Plugin

Introduction

Eclipse has Maven plugin that works without additional maven installation. Theoretically, if all your use of Maven is in eclipse, then there is no need to install standalone Maven. But when you encounter problem to build your project in Eclipse, a standalone Maven becomes handy to help isolate the issue.

Installation

Please follow the Maven Download and Installation instructions on Maven site. At the time of writing, Maven Eclipse plugin uses Maven 2.x, so it is recommended to download and install the latest Maven 2.x instead of 3.x.

JDK: Please be reminded that Maven requires JDK.

Maven Eclipse Plugin (m2e)

Plugin Installation

Please refer to Maven Integration (m2e) section of Install Eclipse and Commonly Used Plugin page.

Import Maven Project

We recommend you to build your Maven project one by standalone Maven before you import to Eclipse. Change directory to the root of your Maven project and run below command:

mvn clean package

Upon successful Maven build, continue to import projects into Eclipse by following the instructions below.

  1. Open Import dialog using Eclipse menu item “File->Import...”
  2. Type “maven” as filter text and select “Maven->Existing Maven Projects”. Then click “Next  >” to continue.
    maven-import
  3. Input directory path to the root of your maven project and press enter key, or use “Browse…” button. Each maven module will be listed in the “Projects” list box. Check the projects that you want to import and click “Finish” button.
    maven-import-projects
  4. The process may take some time to finish importing your project. Please wait for Eclipse to finish its work. Once it is complete, you should see all your imported projects in the Package Explorer. There should be a little blue M at the upper left corner of the project icon.
    maven-import-result

Further Reading

No comments:

Post a Comment