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 ...

Get Maven: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.