mmalohlava / gradle-visteg

Exports task execution graph as .dot file
Apache License 2.0
131 stars 24 forks source link
dotfiles gradle-plugin graph-generation

Gradle VisTEG

Overview

VisTeg is a Gradle plugin for exporting task execution graph as .dot file.

Configuration

Apply visteg plugin

Gradle 1.x and 2.0

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'gradle.plugin.cz.malohlava:visteg:1.0.5'
    }
}

apply plugin: 'cz.malohlava.visteg'

Gradle 2.1 and higher

plugins {
  id 'cz.malohlava.visteg' version '1.0.5'
}

Configure graph generator

The plugin publishes visteg extension with following configuration options:

visteg {
    enabled        = true
    colouredNodes  = true
    colouredEdges  = true
    destination    = 'build/reports/visteg.dot'
    exporter       = 'dot'
    colorscheme    = 'spectral11'
    nodeShape      = 'box'
    startNodeShape = 'hexagon'
    endNodeShape   = 'doubleoctagon'
}

The plugin supports the following options:

Graph generation

Perform any Gradle task, for example build:

./gradlew build

It will generate a .dot file in the directory build/reports containing execution plan graph for task build.

Image generation

The generated file can be post-processed via Graphviz dot utility.

For example, png image is produced as follows:

cd build/reports/
dot -Tpng ./visteg.dot -o ./visteg.dot.png

For more information, please visit Graphviz home page.

Design

The plugin installs itself as a listener to Gradle lifecycle via gradle.taskGraph.whenReady. During execution it obtains reference to task execution graph via reflection and performs a walk through the graph.

Acknowledgements

Based on idea published by Code Wader - http://codewader.blogspot.com/2011/11/show-gradle-dependencies-as-graphwiz.html