You are previewing Maven: The Definitive Guide.

Maven: The Definitive Guide

Cover of Maven: The Definitive Guide by Sonatype Company Published by O'Reilly Media, Inc.

Analyzing Project Dependencies in m2eclipse

The latest release of m2eclipse contains a POM editor that provides some dependency analysis tools. These tools promise to change the way users maintain and monitor a project’s transitive dependencies. One of Maven’s main attractions is the fact that it manages a project’s dependencies. If you are writing an application that depends on the Spring Framework’s Hibernate3 integration, all you need to do is depend on the spring-hibernate3 artifact from the central Maven repository. Maven then reads this artifact’s POM and adds all of the necessary transitive dependencies. Although this is a great feature that attracts people to Maven in the first place, it can become confusing when a project depends on tens of dependencies, each with tens of transitive dependencies.

Problems begin to occur when you depend on a project with a poorly crafted POM that fails to flag dependencies as optional, or when you start encountering conflicts between transitive dependencies. If one of your requirements is to exclude a dependency such as commons-logging or the servlet-api, or if you need to find out why a certain dependency is showing up under a specific scope you will frequently need to invoke the dependency:tree and dependency:resolve goals from the command-line to track down the offending transitive dependencies.

This is where the POM editor in m2eclipse comes in handy. If you open a project with many dependencies, you can open the Dependency Tree tab and ...

The best content for your career. Discover unlimited learning on demand for around $1/day.