Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gradle to find dependency tree

Tags:

gradle

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.

like image 719
user3286701 Avatar asked Feb 08 '14 10:02

user3286701


People also ask

How do you read a Gradle dependency tree?

In Gradle dependencies are libraries required to build your code. Each of these libraries may have their own dependencies, adding transitive dependencies to your project. This structure is called the Gradle dependency tree, with its own rules on dependency conflict resolution and more.

What does -> mean in Gradle dependency tree?

It means that dependency graph contains multiple dependencies with the same group and module but different versions for e.g. org.

How to render dependency tree in Gradle?

You can render the dependency tree with the command gradle dependencies. For more information check the section Listing dependencies in a project in the online user guide. When I do this with my Android project, all I get is this output: pastebin.com/fHFigAuY Suggestions?

How is runtime runtimeclasspath created in Gradle?

runtimeClasspath is created from the dependencies declared against the implementation and runtimeOnly dependency configurations For a full list of dependency configurations check out the Java plugin docs. Every Gradle project comes with a dependencies task which prints a dependency report, including the dependency tree.

How do I get the Gradle projects view?

how do i get the "gradle projects" view? @user3526 click on the "gradle" tag found on the right side of your screen. Look at the attached image for reference I found that this creates a flat list in AS 3.2.0, instead of a tree. The command line variant creates a tree however. @Tom run 'depencies' task under 'help' category not 'android'.

How do I run a Gradle task from an app?

On the right side, open the gradle tab > click the gradle icon (execute gradle task), in the popup dialog enter : This worked for me once I removed app: and just executed dependencies. This gives more useful output than the method in norbDEV's answer as it shows a dependency tree.


3 Answers

Without modules:

gradle dependencies

For Android:

 gradle app:dependencies

Using gradle wrapper:

./gradlew app:dependencies

Note: Replace app with the project module name.

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>
like image 180
Chad Bingham Avatar answered Oct 17 '22 09:10

Chad Bingham


You can render the dependency tree with the command gradle dependencies. For more information check the section Listing dependencies in a project in the online user guide.

like image 274
Benjamin Muschko Avatar answered Oct 17 '22 07:10

Benjamin Muschko


If you find it hard to navigate console output of gradle dependencies, you can add the Project reports plugin:

apply plugin: 'project-report'

And generate a HTML report using:

$ ./gradlew htmlDependencyReport

Report can normally be found in build/reports/project/dependencies/index.html

It looks like this: enter image description here

like image 193
Devstr Avatar answered Oct 17 '22 07:10

Devstr