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 build.gradle file?

Thank you in advance.


  • 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.