How to print task graph?

Is there a way to print the task graph as a tree, in a way that shows all task dependencies?
I’m looking for something in the spirit of the command gradle dependencies, but that shows a tree of tasks instead of artifacts.

1 Like
gradle tasks --all

lists all tasks, and the dependencies for each task.

The new Gradle model can also list tasks created by Rules, with lots of info on them.
To use it, launch gradle model

@Francois_Guillot gradle tasks --all does work.
However, I was looking for something that gives more of a tree view, so that I can easily detect what causes a specific task to run, for instance if I want to check why the task myCustomTask runs when I run gradle build. This can involve a series of transitive dependencies, thus a tree view would be clearer.

there is a plugin for plotting the task graph. Check out
https://plugins.gradle.org/plugin/cz.malohlava it served me well in the
past for visualizing task dependencies.

2 Likes

Another option: https://github.com/jakeouellette/inspector/

2 Likes

Thanks @Rene & @Dan_Stine.

Both work nicely.
VisTEG ( https://plugins.gradle.org/plugin/cz.malohlava ) is simple and does pretty much what I was asking for.

Though I wish there was a plugin that simply prints the task dependency tree directly to the console, just like gradle dependencies does for artifacts.

Maybe I’ll give it a shot and try to develop such a plugin myself…

2 Likes

:thumbsup: for a custom plugin here. Ensure this plugin makes it into the gradle plugin portal

OK. I made a custom plugin.
For those interested in using it, see here:

https://plugins.gradle.org/plugin/com.dorongold.task-tree

6 Likes

This is awesome! I’d love to see it included as an implicit plugin as part of gradle core

3 Likes

The plugin does not seem to work anymore. I cleared my ~/.gradle cache, and the project cache to be sure. I use Gradle 3.0-milestone-1

  • What went wrong:
    An exception occurred applying plugin request [id: ‘com.dorongold.task-tree’, version: ‘1.2.1’]

Failed to apply plugin [id ‘com.dorongold.task-tree’]
Could not generate a proxy class for class com.dorongold.gradle.tasktree.TaskTreeTask.

In gradle version 2.14 a gradle class used by this plugin was deprecated and moved to a different internal package.
I committed a fix and published to gradle plugin portal a new version of Task Tree Plugin: 1.2.2.
Tested the fix successfuly on gradle versions 2.14 and 3.0-milestone-2.

Version 1.2.2 of the plugin will only work with gradle versions 2.14+.
Version 1.2.1 of the plugin must be used for gradle vresions 2.3-2.13.

3 Likes

It works fine! Just what I was looking for.
Using gradle 3.1

1 Like

Ha, I made a custom plugin, too. :blush: Just sharing because in addition to showing the task graph as a tree, it can also print the execution queue (which tasks will be executed in which order), and make a JSON export in case the information needs parsing. Maybe this will help someone. Gradle rocks!

2 Likes