Determine source of transitive dependency

Tag: gradle Author: IAMXUQIN Date: 2013-06-29

I have a project in which I am using sl4j with log4j. I recently added a few new dependencies to my project, and one of these new dependencies that I added is including a transitive dependency to logback-classic, which includes another binding for sj4j.

I want to get rid of logback, but I have no clue which of my direct dependencies added the transitive dependency so that I can exclude it.

In maven I know how to get the entire graph of dependencies to determine which is the source of a transitive dependency, but I have no clue of how to do this with gradle.

Does anyone knows how to get the source dependency of a transitive dependency with gradle?

Best Answer

To show the whole dependency tree for each class path, use gradle dependencies. If you are only interested in a particular class path, use (say) gradle dependencies --configuration compile.

To show who pulls in a particular dependency onto a particular class path, and how any version conflicts were resolved, use (say) gradle dependencyInsight --dependency logback --configuration compile.

Note that you can also exclude a dependency from a whole class path (or multiple). Usually this is more reliable then excluding a particular transitive dependency. For example:

configurations.all*.exclude module: "logback-classic"