Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Introduction to Apache Maven 2

Sing Li (, Author, Wrox Press
Photo of Sing Li
Sing Li is a consultant and an active author with more than two decades of industry experience. He has contributed to Professional Apache Geronimo, Beginning JavaServer Pages, Professional Apache Tomcat 5, Pro JSP - Third Edition, Early Adopter JXTA, Professional Jini, Beginning J2ME: From Novice to Professional, Third Edition, Professional Apache Geronimo, and numerous other books. Sing also writes for technical magazines and participates in open source communities. He is an evangelist of the open source, VOIP, and P2P movements. You can reach Sing at

Summary:  Modern software projects are no longer solely monolithic creations of single local project teams. With the increased availability of robust, enterprise-grade open source components, today's software projects require dynamic collaboration among project teams and often depend on a mix of globally created and maintained components. Now in its second generation, the Apache Maven build system -- unlike legacy build tools created before the Internet-enabled era of global software development -- was designed from the ground up to take on these modern challenges. This tutorial gets you started with Maven 2.

Date:  19 Dec 2006
Level:  Intermediate

Activity:  152623 views

Working with the Maven 2 Plug-in for Eclipse 3.2

This section covers some of the frequently used features of the Maven 2.x Plug-in for Eclipse.

You need to enable Maven nature on an Eclipse project before the Maven 2 plug-in features are available with your project. Right-click on the project that you want to add Maven support to and select Maven2>Enable.

To ensure your project's directory structure reflects Maven's expectations, you should create your Maven directory structure (either manually or using an Archetype) first and then add the project to Eclipse.

Live repository search for dependencies

Adding dependencies to a pom.xml is easy using the plug-in. Right-click on the project's pom.xml and select Maven2>Add Dependency. This starts the Repository Search wizard. Type the first few characters of the name of the dependency you're looking for, and the wizard searches the central repository for any matching artifacts. All details of the matching artifacts are presented to you to help you select the dependency. Figure 11 shows the results of a search for JUnit artifacts:

Figure 11. Maven Repository Search wizard
Maven Repository Search wizard

Once you have selected the artifact version you want and click OK, a new <dependency> element is added to the pom.xml by the plug-in automatically.

Invoking a Maven build

A build involving any of the life-cycle phases can be started from Eclipse. First, make sure the Maven-enabled project is currently open. Then, from the Eclipse menu, select Run>External Tools>External Tools.... This displays the External Tools wizard, as shown in Figure 12:

Figure 12. Building via Maven using the Eclipse External Tool wizard
Building via Maven using Eclipse External Tools wizard

Give this configuration a name and then select a life-cycle phase by clicking the Goals... button. Click Run to run Maven.

The Maven output is displayed on Eclipse's Console tab.

11 of 15 | Previous | Next


Zone=Java technology, Open source
TutorialTitle=Introduction to Apache Maven 2