# Get dependency graph from files

**URL:** <https://discuss.gradle.org/t/get-dependency-graph-from-files/26835>\
**Category:** Help/Discuss\
**Created:** [May 5, 2018, 12:24am UTC](https://discuss.gradle.org/t/get-dependency-graph-from-files/26835 "2018-05-05T00:24:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjbell4](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rjbell4](https://discuss.gradle.org/u/rjbell4)\
**Post date:** [May 5, 2018, 12:24am UTC](https://discuss.gradle.org/t/get-dependency-graph-from-files/26835/1 "2018-05-05T00:24:42Z")

</div>

I have a project (actually, a multi-project) where the inputs and outputs are connected through `RegularFileProperty`s. This works great to sequence my tasks, even in parallel.

I’d really like to be able to generate some sort of dependency graph, so that we can better understand the relationship between the tasks (and projects). However, I don’t see any way to do that. The `dependencies` task doesn’t report on the dependencies between the tasks, as I’ve specified them. Even if I take pains to use a `dependencies` closure to also declare my dependencies that way (as `FileCollection`s), the `dependencies` task doesn’t report anything; it seems that the `dependencies` task doesn’t consider `FileCollection`s when printing its report.

Basically, I’m asking to consider the consumer and producer example from the official Gradle documentation here: [https://docs.gradle.org/current/userguide/lazy\_configuration.html#sec:working\_with\_task\_dependencies\_in\_lazy\_properties](https://docs.gradle.org/current/userguide/lazy_configuration.html#sec:working_with_task_dependencies_in_lazy_properties)  
In that simple example, what can be done to be able to show the relationship between the `consumer` and `producer` tasks?

---

<div class="post-metadata">

**Author:** ![rjbell4](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rjbell4](https://discuss.gradle.org/u/rjbell4)\
**Post date:** [May 5, 2018, 8:54pm UTC](https://discuss.gradle.org/t/get-dependency-graph-from-files/26835/2 "2018-05-05T20:54:22Z")

</div>

FYI, at the moment the best I have is manually adding some code like the following:

```gradle
String label(Task task) {
    return task.path.substring(1).replaceAll(':myTask$', '')
}

gradle.taskGraph.with {
    whenReady { 
        mkdir project.buildDir
        File gv = new File(project.buildDir, "deps.gv")
        File png = new File(project.buildDir, "deps.png")
        gv.text = "digraph deps {\n"
        allTasks.each { task -> 
            getDependencies(task).each { dep ->
                gv.text += " \"${label(task)}\" -> \"${label(dep)}\"\n"
            }
        }
        gv.text += "}\n"
        ("dot -Tpng " + gv.path + " -o " + png.path).execute()
    }
}

```

---

<div class="post-metadata">

**Author:** ![fredc](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredc](https://discuss.gradle.org/u/fredc)\
**Post date:** [May 6, 2018, 7:11am UTC](https://discuss.gradle.org/t/get-dependency-graph-from-files/26835/3 "2018-05-06T07:11:01Z")

</div>

The built-in `dependencies` task displays module dependencies, not task dependencies.

There are several third-party plugins for visualizing the task graph, e.g., [https://github.com/dorongold/gradle-task-tree](https://github.com/dorongold/gradle-task-tree).
