How to print out all dependencies in a Gradle multi-project build?

Viewed 9821

I have a Gradle multi-project build with a master-directory where common definitions are located and some projects that are defined in settings.gradle via include statements.

Building, testing, runnings all works fine, but showing dependencies via task dependencies does not work, it only prints:

$ g dependencies
master
:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

No configurations

BUILD SUCCESSFUL

Doing gradle :project1:dependencies in the master-directory works as expected.

How can I get Gradle to print out the whole dependency tree including all the third party libraries for all the projects that are included?

3 Answers

Unfortunately, you have to specify your own task:

allprojects {
    task printAllDependencies(type: DependencyReportTask) {}
}

And after that, execute: ./gradlew printAllDependencies.
In case if you don't want to see dependencies for the root project, put this task to the subprojects block.

subprojects {
    task printSubDependencies(type: DependencyReportTask) {}
}


Suppose you need it to find a certain dependency. In this case, you can use the power of the dependencyInsight task.

subprojects {
    task findDependency(type: DependencyInsightReportTask) {}
}

And after that run

./gradlew findDependency --configuration compile --dependency spring-data-jpa
Related