Analyzing project dependencies

A POM editor has a Dependencies tab that provides a glance of dependencies and an option to manage dependencies of the project. The Dependencies tab has two sections as shown in the following screenshot:

Analyzing project dependencies

It shows all the dependencies of the project on the left side. We can also add dependencies to the project using the Add button of the Dependencies section. The Manage button allows you to choose the POM that will manage the corresponding dependencies, and the screenshot for this is shown as follows:

Analyzing project dependencies

As stated very clearly on the top of the window, the managed dependencies version information will move to the POM that manages it. For example, let's choose to manage the log4j dependency of distance-webapp by the Distance-main POM. Select log4j on the list to the and select Distance-main in the list to the right, and click on OK as shown in the following screenshot:

Analyzing project dependencies

After the log4j file is managed, the word "managed" appears to its right, as shown in the following screenshot:

Analyzing project dependencies

If we happen to see its effect in the XML file, we can see that the version information from the distance-webapp POM is moved and is added as a dependency in the Distance-main POM, as shown in the following code:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Another way to achieve the same functionality is via the Dependency Management section to the right across the parent-child POM. The Dependency Hierarchy tab contains two sections: Dependency Hierarchy and Resolved Dependencies as follows:

Analyzing project dependencies

The Dependency Hierarchy section on the left provides the tree view of the dependencies. The first level of the tree is direct dependency of the project and then each subsequent level shows the dependencies of each dependency. The preceding screenshot is for the distance-webapp module, where we have four direct dependencies, and these dependencies have no further dependency, so the tree structure is not visible. However, for large projects and large direct dependencies, we can easily visualize it. The jar icon indicates that it is referenced from the Maven repository and the open folder icon indicates its presence in the Eclipse workspace.

The Resolved Dependencies section on the right shows the list of all resolved dependencies, that is, resulting dependencies after all conflicts and scopes applied. It gives a general idea of resolution chain propagation and route to Resolved Dependencies. Click on any resolved dependency and its shows the dependency chain in the Dependency Hierarchy section.

For more information on dependencies, refer to http://books.sonatype.com/m2eclipse-book/reference/dependencies-sect-analyze-depend.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.242.235