Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering available Gradle tasks by task group

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.

like image 824
stefanglase Avatar asked Jan 11 '12 13:01

stefanglase


3 Answers

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

Gradle docs.

like image 149
lupchiazoem Avatar answered Nov 15 '22 23:11

lupchiazoem


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

like image 41
Balazs Banyai Avatar answered Nov 16 '22 00:11

Balazs Banyai


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://stackoverflow.com/a/54341658/4433326

like image 2
Peter Niederwieser Avatar answered Nov 15 '22 23:11

Peter Niederwieser