Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine source of transitive dependency

Tags:

gradle

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?

like image 917
Edwin Dalorzo Avatar asked Jul 15 '13 15:07

Edwin Dalorzo


People also ask

How do you find transitive dependency?

When an indirect relationship causes functional dependency it is called Transitive Dependency. If P -> Q and Q -> R is true, then P-> R is a transitive dependency. To achieve 3NF, eliminate the Transitive Dependency.

How do you resolve transitive dependencies in Gradle?

A variant of a component can have dependencies on other modules to work properly, so-called transitive dependencies. Releases of a module hosted on a repository can provide metadata to declare those transitive dependencies. By default, Gradle resolves transitive dependencies automatically.

How do I determine which POM contains missing transitive dependency?

How do I determine which POM contains missing transitive dependency? Ans. If its already there in Maven local repository, We can add that as a dependency in the project pom file with its Group Id, Artifact Id and version.


1 Answers

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

Use the -p option to run on a sub-project.

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 than excluding a particular transitive dependency. For example:

configurations.all*.exclude module: "logback-classic"
like image 159
Peter Niederwieser Avatar answered Oct 05 '22 20:10

Peter Niederwieser