3

I only have this in my build.gradle file

project.task ("Task1")
task("Task2")
task Task3

I am using Gradle version 3.5 and when I execute

gradle tasks

in command line, no tasks are shown. But when I do

gradle tasks --all

, then I can see my tasks

Other tasks
-----------
Task1
Task2
Task3

Do we need to always use gradle tasks --all to see all the tasks? In some tutorial website, they just use gradle tasks and all tasks will be shown. Wondering where do I do wrongly here. Thanks.

keylogger
  • 822
  • 3
  • 19
  • 39
  • https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:listing_tasks – JB Nizet Apr 17 '17 at 08:42
  • Whoever they are who gave my question -1 , Are you already a Gradle expert since you were born without doing trial & error? @JBNizet I read that document and didn't understand why we need 'gradle tasks -all' , meanwhile in the tutorial it can be done with 'gradle tasks' , thus I ask question. 'gradle -q tasks' doesn't do either. – keylogger Apr 17 '17 at 09:01
  • Sorry, but you don't need to be an expert to be able to understand *By default, this report shows only those tasks which have been assigned to a task group, so-called visible tasks. You can do this by setting the group property for the task. [example]* If you can't understand that when reading the documentation, I don't see how any answer could help. – JB Nizet Apr 17 '17 at 09:08
  • 4
    Possible duplicate of [Why can't see all task when use 'tasks' task in Gradle?](http://stackoverflow.com/questions/23185321/why-cant-see-all-task-when-use-tasks-task-in-gradle) – JB Nizet Apr 17 '17 at 09:20
  • Not to mention that copying and pasting the title of your question in google, and clicking on the **first** link returned by google, links to another similar question which has the answer. No need to be an expert to use google, either. – JB Nizet Apr 17 '17 at 09:21

1 Answers1

5

I think, the reason is that according to the documentation the gradle tasks command:

shows only those tasks which have been assigned to a task group, so-called visible tasks. You can do this by setting the group property for the task. You can also set the description property, to provide a description to be included in the report.

You can read about it in the official documentation here.

P.S.: in my case, with Grdale 2.14.1, command gradle tasks lists all the tasks, even though documentation for this version says the same as for 3.5, that it should lists only grouped tasks by default.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • 1
    Thank you. That may explain why in the tutorial he can just do `gradle tasks` and list all the tasks. He used Gradle 2.4. Meanwhile using Gradle 3.5, I can't do that. Thanks for the explanation. – keylogger Apr 17 '17 at 09:42
  • Just to clarify: as per my experimentation (Gradle 4.4.1) setting the "description" won't cause your task to be listed... but setting "group" (to any group name, including one you just made up) will... – mike rodent Jan 04 '18 at 20:33