Giter Club home page Giter Club logo

gradle-dependency-graph-generator-plugin's Introduction

gradle-dependency-graph-generator-plugin

Gradle plugin that lets you visualize your dependencies in a graph.

Set up

Gradle 3.3 or higher is required.

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.5.0"
  }
}

apply plugin: "com.vanniktech.dependency.graph.generator"

Note that this plugin can be applied at the root of the project or at a specific project. Both cases will just work.

Information: This plugin is also available on Gradle plugins

Snapshot

buildscript {
  repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  }
  dependencies {
    classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.6.0-SNAPSHOT"
  }
}

apply plugin: "com.vanniktech.dependency.graph.generator"

Usage

By default this plugin will generate a generateDependencyGraph task that can be used to generate a dependency graph that could look like this. This graph was generated from my chess clock app.

Example graph.

There are extension points to be able to generate graphs which only include some dependencies and their transitive ones. The trick is to hook a Generator in over the dependencyGraphGenerator extension. Note that this is extremely experimental and will likely change between releases. It's still fun though.

Generator Example

We only want to show which Firebase libraries we're using and give them the typical Firebase orange.

import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorPlugin
import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorExtension.Generator
import guru.nidi.graphviz.attribute.Color
import guru.nidi.graphviz.attribute.Style

plugins.apply(DependencyGraphGeneratorPlugin)

def firebaseGenerator = new Generator(
  "firebaseLibraries", // Suffix for our Gradle task.
  { dependency -> dependency.getModuleGroup().startsWith("com.google.firebase") }, // Only want Firebase.
  { dependency -> true }, // Include transitive dependencies.
  { node, dependency -> node.add(Style.FILLED, Color.rgb("#ffcb2b")) }, // Give them some color.
)

dependencyGraphGenerator {
  generators = [ firebaseGenerator ]
}

This will generate a new task generateDependencyGraphFirebaseLibraries which when run will yield this graph:

Example Firebase graph.

Note that when using the dependencyGraphGenerator extension with custom generators you lose the default one, to add it back simply use the Generator.ALL instance:

dependencyGraphGenerator {
  generators = [ Generator.ALL, firebaseGenerator ]
}

License

Copyright (C) 2018 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0

gradle-dependency-graph-generator-plugin's People

Contributors

alexkorovyansky avatar gengjiawen avatar johnjohndoe avatar rmtheis avatar thunderforge avatar vanniktech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.