Using gradle to find dependency tree

user3286701 picture user3286701 · Feb 8, 2014 · Viewed 454.5k times · Source

Is it possible to use gradle to produce a tree of what depends on what?

I have a project and would like to find out all the dependencies so I may be able to prune it a little with forward declarations etc.

Answer

Chad Bingham picture Chad Bingham · Feb 6, 2016

For Android, use this line

 gradle app:dependencies

or if you have a gradle wrapper:

./gradlew app:dependencies

where app is your project module.

Additionally, if you want to check if something is compile vs. testCompile vs androidTestCompile dependency as well as what is pulling it in:

./gradlew :app:dependencyInsight --configuration compile --dependency <name>
./gradlew :app:dependencyInsight --configuration testCompile --dependency <name>
./gradlew :app:dependencyInsight --configuration androidTestCompile --dependency <name>

If the application doesn't use modules, try:

gradle dependencies