Search code examples
javagradledependenciesbuild-dependencies

Limit displayed depth of gradle dependencies task


Using gradle dependencies I get a huge list of all dependencies. Showing all dependencies the projects I depend on have. Is it possible to limit the depth of the shown list?
Example:

+--- com.company.common:e-common-junit:0.29.0-SNAPSHOT
|    +--- junit:junit:4.11 (*)
|    \--- commons-io:commons-io:2.4
\--- org.slf4j:slf4j-log4j12:1.7.6
     +--- org.slf4j:slf4j-api:1.7.6
     \--- log4j:log4j:1.2.17

Limited to only +--- com.company.common:e-common-junit:0.29.0-SNAPSHOT
From the gradle site:

dependencies - Displays all dependencies declared in root project 'projectReports'.
api:dependencies - Displays all dependencies declared in project ':api'.
webapp:dependencies - Displays all dependencies declared in project ':webapp'.

It even mentiones that these reports can get large at this official source.
Stating that I should use --configuration, but as far as my understanding of this article goes it would only limit it to compile, testCompile and so on, not in depth.
Version in use gradle 2.11


Solution

  • Use grep:

    • Show only top level dependencies:
      gradle dependencies --configuration compile | grep -v '| '

    • Show two levels:
      gradle dependencies --configuration compile | grep -v '| | '

    etc