Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
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...