Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 650
Peter Avatar asked Oct 12 '16 15:10

Peter


People also ask

What does -> mean in Gradle dependencies?

It means that dependency graph contains multiple dependencies with the same group and module but different versions for e.g. org.

What is Gradle dependency constraint?

Dependency constraints allow you to define the version or the version range of both dependencies declared in the build script and transitive dependencies. It is the preferred method to express constraints that should be applied to all dependencies of a configuration.

How do I resolve Gradle dependencies?

Given a required dependency, with a version, Gradle attempts to resolve the dependency by searching for the module the dependency points at. Each repository is inspected in order. Depending on the type of repository, Gradle looks for metadata files describing the module ( .

What is runtimeClasspath in Gradle?

main. runtimeClasspath' contains the compiled classes of the source set, and task autowiring automatically adds the necessary task dependencies. Maybe you want 'sourceSets. main. compileClasspath'.


1 Answers

Use grep:

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

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

etc

like image 137
RaGe Avatar answered Sep 24 '22 21:09

RaGe