tir38
tir38

Reputation: 10451

How to list all Gradle projects in multi-project build

I have a project with several Gradle modules (I think Gradle just calls these sub-projects). Basically I have a bunch of projects/modules listed in settings.gradle. Is there a Gradle command to print each one (either name or ideally a supplied label/description)

Upvotes: 14

Views: 11220

Answers (2)

Stephen Talley
Stephen Talley

Reputation: 1202

From within a module's build.gradle.kts, you can use:

rootProject.allprojects.forEach {
    println("Project: ${it.name}")
}

Upvotes: 0

sschuberth
sschuberth

Reputation: 29867

Unspectacularly, that task is simply called "projects", and (if you are using the Gradle wrapper) ./gradlew projects executed at the root project lists all sub-projects.

In general, if you are looking for a task, your chances are good that you can guess its name from the task list shown by ./gradlew tasks.

Upvotes: 21

Related Questions