Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list only the custom tasks in a Gradle build file?

I have written a gradle build file which several custom tasks. They are all like the following:

task runThis(type:JavaExec) {
    doSomething()
}

When I enter "gradle tasks" in a terminal, none of the tasks I have written myself are listed. Only the standard list of tasks which appear when I run this command against a new project.

How do I get the tasks to be listed? And is it possible to print ONLY the custom written tasks?

like image 365
radiobrain77 Avatar asked Dec 09 '25 11:12

radiobrain77


1 Answers

I think gradle tasks --all should works, and your customized tasks are in Other tasks category.

In intellij, there is a panel called Gradle projects. enter image description here


only the custom tasks: I write a simple task to do the trick:

// run with  `gradle printTasks`
task printTasks << {
    project.tasks.collect {
        task ->
            if (!task.group && task.name !='printTasks') {
                println task.name
            }
    }
}
like image 80
aristotll Avatar answered Dec 11 '25 20:12

aristotll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!