1

I have been learning about the Gradle system for Android recently. We know that if we put "gradle tasks --all" in the command line, Gradle will print out all the available tasks.

What interests me is the list of subtasks under the task "assembleDebug"(such as "bundleDebug", "compileDebugNdk" etc.). I assume they are subtasks by the indention in front of them.

Will all these subtasks be executed if we run "assembleDebug" task? If so, what's the order of execution? If not, which ones will be picked up?

Note: The subtasks below seem to be listed lexicographically. So we cannot assume it is the execution order.

enter image description here

auspicious99
  • 3,902
  • 1
  • 44
  • 58
hackjutsu
  • 8,336
  • 13
  • 47
  • 87

2 Answers2

3

the output you posted here means that assembleDebug depends on the other task listed here in indention. The best way to figure out exactly in which order tasks gets executed, you can run gradle :api:assembleDebug -m to "dry run" your build. In general "SubTask" is not the usual term here. instead I would say that assembleDebug depends on these tasks.

Rene Groeschke
  • 27,999
  • 10
  • 69
  • 78
0

Firstly, the official terminology is not subtasks, but "task dependencies". And regarding the order of execution, officially it is "task ordering". See the official Gradle docs, particularly the section entitled Task Dependencies and Task Ordering. It says:

A task may have dependencies on other tasks or might be scheduled to always run after another task. Gradle ensures that all task dependencies and ordering rules are honored when executing tasks, so that the task is executed after all of its dependencies and any "must run after" tasks have been executed.

Secondly, you can use gradle --dry-run :api:assembleDebug (or -m as a synonym for --dry-run, as the other answer suggests). The output is according to the Task Ordering, not lexicographical ordering.

NB: be careful not to be confused between "dependencies" and "task dependencies". "Dependencies" by itself, are Java dependencies, e.g., libraries, that are needed for the build, and you might use gradle api:dependencies to see those. See this SO post for more info on Java dependencies.

auspicious99
  • 3,902
  • 1
  • 44
  • 58