Book Image

Apache Maven Cookbook

By : Raghuram Bharathan
Book Image

Apache Maven Cookbook

By: Raghuram Bharathan

Overview of this book

If you are a Java developer or a manager who has experience with Apache Maven and want to extend your knowledge, then this is the ideal book for you. Apache Maven Cookbook is for those who want to learn how Apache Maven can be used for build automation. It is also meant for those familiar with Apache Maven, but want to understand the finer nuances of Maven and solve specific problems.
Table of Contents (13 chapters)
12
Index

Getting into dependency and avoiding dependency hell


As you use a number of dependencies, each of them in turn may also include further dependencies. A situation may come when there are multiple versions of the same dependencies in the project. This can often lead to errors.

Getting ready

To understand this, we need to have a fairly complex project that has several transitive dependencies. You can look at one such project at https://github.com/selendroid/demoproject-selendroid.

Clone the repository on your system. Now, we are ready to see how complex dependencies can get.

How to do it...

Use the following steps to avoid dependency hell:

  1. Run the following command:

    mvn dependency:tree -Dverbose
    
  2. Note the output as shown in the following screenshot:

How it works...

As you can see, in the course of identifying the dependencies to be used in the project, Maven does a dependency analysis. This reveals two things:

  • Two or more dependencies require the same version of another dependency. Maven includes a dependency...