Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list gradle dependencies for all subprojects

I can query the dependency tree for a Gradle project with ./gradlew -q dependencies.

I can also run the query for the service subproject with ./gradlew service:dependencies.

How can I list the dependencies automatically for all subprojects from the command line without modifying the gradle.properties file?

Thank you in advance.

like image 713
erdos Avatar asked Jan 22 '21 20:01

erdos


1 Answers

I believe there’s no built-in way in Gradle to achieve this (without adapting the build configuration) – unless you manually list the dependencies task for all subprojects as in:

./gradlew sub1:dependencies sub2:dependencies sub1:subsub:dependencies

However, if you need this feature often enough, then you could create a shell alias for it. Example in bash (e.g., put this in your ~/.bashrc file):

alias gradle-all-deps='./gradlew dependencies $(./gradlew -q projects \
    | grep -Fe ---\ Project \
    | sed -Ee "s/^.+--- Project '"'([^']+)'/\1:dependencies/"'")'

Then simply call gradle-all-deps from the root project directory.

like image 61
Chriki Avatar answered Oct 18 '22 13:10

Chriki