Skip to content

FairyDevicesRD/HiltBlueprint

Repository files navigation

Hilt Blueprint

A plugin that visualizes Dagger/Hilt dependency graphs.
It outputs SVG or DOT (Graphviz) format without requiring any additional tools.

Example: https://github.com/android/architecture-samples

日本語 README はこちら

Features

This plugin is implemented solely in Kotlin, with minimal external dependencies.
It renders the graph following the Hilt scope component hierarchy.

How it works

It uses the Dagger compiler's SPI (Service Provider Interface)
to capture the binding graph at compile time, generate a DOT file, and convert it to SVG.

Setup

MavenCentral

// settings.gradle.kts
pluginManagement {
    repositories {
        mavenCentral() // required!!
    }
}

dependencyResolutionManagement {
    repositories {
        mavenCentral() // required!!
    }
}

Apply the plugin to the Android app module whose graph you want to output.

// app/build.gradle.kts
plugins {
    id("com.android.application")
    id("com.google.devtools.ksp")
    id("com.google.dagger.hilt.android")
    id("io.github.fairydevicesrd.hiltblueprint") version "0.1.0" // here!!
}

When using libs.versions.toml:

[versions]
hiltBlueprint = "0.1.0"

[plugins]
hilt-blueprint = { id = "io.github.fairydevicesrd.hiltblueprint", version.ref = "hiltBlueprint" }

Usage

# Output as SVG (recommended — zoomable in a browser, no Graphviz installation required)
./gradlew :app:generateHiltBlueprintSvg

# Output DOT only
./gradlew :app:generateHiltBlueprintDot

Output location: {module}/build/reports/hilt-blueprint/{ApplicationName}.svg / .dot

Note

After clean, if the DOT file is missing but the build cache hits, Hilt compilation may be skipped and the DOT file will not be regenerated. In that case, add --rerun-tasks.

./gradlew :app:generateHiltBlueprintSvg --rerun-tasks

Node colors

Color Meaning
Blue (#E3F2FD) @Provides
Orange (#FFF3E0) @Binds
Green (#E8F5E9) @Inject constructor
Gray (#F5F5F5) Others (multibinding, etc.)

Supported versions

  • Dagger / Hilt: 2.48 or later
  • KSP: 2.1.10-1.0.29 or later
  • Gradle: 8.0 or later

Verified with

License

MIT License

About

Dagger2 SPI を利用した依存関係をSVG/DOT で可視化するプラグイン

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages