https://github.com/vanniktech/gradle-dependency-graph-generator-plugin
Gradle plugin that generates dependency graphs from your project.
https://github.com/vanniktech/gradle-dependency-graph-generator-plugin
Last synced: 7 months ago
JSON representation
Gradle plugin that generates dependency graphs from your project.
- Host: GitHub
- URL: https://github.com/vanniktech/gradle-dependency-graph-generator-plugin
- Owner: vanniktech
- License: apache-2.0
- Created: 2018-03-02T23:26:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T13:30:46.000Z (7 months ago)
- Last Synced: 2025-05-13T14:52:17.453Z (7 months ago)
- Language: Kotlin
- Homepage: http://vanniktech.com
- Size: 1.05 MB
- Stars: 1,583
- Watchers: 28
- Forks: 101
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-kotlin - gradle-dependency-graph-generator-plugin - Gradle plugin that generates dependency graphs from your project. (Libraries)
README
# gradle-dependency-graph-generator-plugin
Gradle plugin that lets you visualize your dependencies in a graph.
# Set up
[Gradle 3.3](https://docs.gradle.org/3.3/release-notes.html) or higher is required.
```gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.8.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.
### Snapshot
```gradle
buildscript {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.9.0-SNAPSHOT"
}
}
apply plugin: "com.vanniktech.dependency.graph.generator"
```
## Usage
By default, this plugin provides two reporting tasks:
| `generateDependencyGraph` | `generateProjectDependencyGraph` |
|:--------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------|
|  |  |
| Generates a **complete** dependency graph in `build/reports/dependency-graph/` | Generates a dependency graph of the **project modules** in `build/reports/project-dependency-graph/` |
_Source project: [vanniktech/Emoji](https://github.com/vanniktech/Emoji)_
The graphs are generated in `.png`, `.svg` & `.dot` format.
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](./src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorExtension.kt) 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 Jetbrains libraries we're using.
```groovy
import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorPlugin
import guru.nidi.graphviz.attribute.Color
import guru.nidi.graphviz.attribute.Style
plugins.apply(DependencyGraphGeneratorPlugin)
dependencyGraphGenerator {
generators {
jetbrainsLibraries {
include = { dependency -> dependency.getModuleGroup().startsWith("org.jetbrains") } // Only want Jetbrains.
children = { true } // Include transitive dependencies.
dependencyNode = { node, dependency -> node.add(Style.FILLED, Color.rgb("#AF1DF5")) } // Give them some color.
}
}
}
```
The same can be done using Kotlin
```kotlin
import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorExtension
import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorPlugin
import guru.nidi.graphviz.attribute.Color
import guru.nidi.graphviz.attribute.Style
plugins.apply(DependencyGraphGeneratorPlugin::class.java)
configure {
generators.create("jetbrainsLibraries") {
include = { dependency -> dependency.moduleGroup.startsWith("org.jetbrains") } // Only want Jetbrains.
children = { true } // Include transitive dependencies.
dependencyNode = { node, dependency -> node.add(Style.FILLED, Color.rgb("#AF1DF5")) } // Give them some color.
}
}
```
This will generate a new task `generateDependencyGraphJetbrainsLibraries` which when run will yield this graph:

# License
Copyright (C) 2018 Vanniktech - Niklas Baudy
Licensed under the Apache License, Version 2.0