Determine source of transitive dependency

ⅰ亾dé卋堺 提交于 2021-02-17 08:35:51

问题


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?


回答1:


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"


来源:https://stackoverflow.com/questions/17657539/determine-source-of-transitive-dependency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!