Filtering available Gradle tasks by task group
Asked Answered
P

3

8

With the command gradle tasks one can get a report of all available tasks. Is there any way to add a parameter to this command and filter tasks by their task group.

I would like to issue a command like gradle tasks group:Demo to filter all tasks and retrieve a list of only those tasks that belong to the task group called Demo.

Perice answered 11/1, 2012 at 13:1 Comment(1)
You should change the accepted answer: Gradle 5.1+ supports it now.Consolute
C
6

From v5.1, you can do this: gradle tasks --group=<group-name>

Gradle docs.

Conaway answered 24/1, 2019 at 7:47 Comment(0)
M
6

You can do so by adding the following task to your build script:

task showOnlyMyTasks << {
    tasks.each {
        task -> if (task.group == 'My task group name') {
        println(task.name)
        }
    }
}

And then run:gradle showOnlyMyTasks

If you need only the list, you can use gradle -q

Mccann answered 10/9, 2013 at 9:52 Comment(0)
C
6

From v5.1, you can do this: gradle tasks --group=<group-name>

Gradle docs.

Conaway answered 24/1, 2019 at 7:47 Comment(0)
B
2

Old answer: There is no such feature. Feel free to suggest new features at http://forums.gradle.org.

Now available since Gradle 5.1, see this answer: https://mcmap.net/q/1283657/-filtering-available-gradle-tasks-by-task-group

Blackmun answered 11/1, 2012 at 13:28 Comment(1)
Everybody: it can be done from v5.1, refer to my answer.Conaway

© 2022 - 2024 — McMap. All rights reserved.