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.
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.
It means that dependency graph contains multiple dependencies with the same group and module but different versions for e.g. org.
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?
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? @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'.
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.
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>
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With