How to print task graph?

(Doron Gold) #1

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.

(François Guillot) #2
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

(Doron Gold) #3

@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.

(René Groeschke) #4

there is a plugin for plotting the task graph. Check out it served me well in the
past for visualizing task dependencies.

(Dan Stine) #5

Another option:

(Doron Gold) #6

Thanks @Rene & @Dan_Stine.

Both work nicely.
VisTEG ( ) 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…

(René Groeschke) #7

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

(Doron Gold) #8

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

(Lance Java) #9

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

(Martin d'Anjou) #10

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.

(Doron Gold) #11

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.

(Miguel Reyes) #12

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