Freewind
Freewind

Reputation: 198388

Can't find an easy way to list all dependencies of a gradle project if it contains multi projects

For a gradle project with multiple sub-projects, if I use:

gradle dependencies

Which can only list the dependencies of root project.

If I want to list all dependencies, I have to use gradle projects to show all sub projects, and then:

gradle :someproject:dependencies

to view them one by one.

Which is very inconvenient, is there any easy way to do it?

Upvotes: 3

Views: 117

Answers (1)

Michael Schaefers
Michael Schaefers

Reputation: 717

Define the following task in your root project:

task allDependencies {
    doLast() {
        subprojects.each { p->
            println "Showing dependencies of ${p}"
            p.tasks.getByName("dependencies").execute()
        }
    }
}

I first tried to call all dependencies via dependsOn, to avoid calling the execute() method, but the following script

task allDependencies { 
}
allprojects {
    rootProject.allDependencies.dependsOn(tasks.getByName("dependencies"))
}

failed with

Task with name 'dependencies' not found in project :Foo

Upvotes: 2

Related Questions