Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 577
centic Avatar asked May 30 '17 15:05

centic


People also ask

How do I get dependencies in Gradle?

Every Gradle project provides the task dependencies to render the so-called dependency report from the command line. By default the dependency report renders dependencies for all configurations. To focus on the information about one configuration, provide the optional parameter --configuration .

Where all Gradle dependencies are stored?

The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.

Are Gradle dependencies stored in builds?

Gradle stores resolved dependencies in its own cache. A build does not need to declare the local Maven repository even if you resolve dependencies from a Maven-based, remote repository.


1 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
like image 183
Max Avatar answered Sep 23 '22 06:09

Max