dead8309 / module-graph

A Gradle Plugin for visualizing your project structure powered by mermaidjs

Home Page:https://plugins.gradle.org/plugin/dev.iurysouza.modulegraph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre Merge Checks License Language

Introducing the Gradle Module Graph Plugin! 🌟

This plugin generates a Mermaid graph for your Gradle project, providing a visual representation of your project's module relationships. By illustrating how the parts of the project are connected, it makes it easier to understand the design and how they depend on each other.

A diagram about the current system is only useful if it's generated. If it is produced by hand it documents the author's belief, not the system. Still, important, but not an input for decision making. Development is primarily decision making. Enable it through custom tools. source

You can read more about the background story of this plugin here.

Features

  • Generates a Mermaid dependency graph of the modules in your Gradle project.
  • Automatically append the generated graph to your project's README file.
  • The raw code block automatically renders as a graph on both Github and Gitlab.

Getting Started

You'll just need to add it to your project's root build.gradle or build.gradle.kts file.

build.gradle (Groovy DSL)

Using the plugins DSL

plugins {
    id "dev.iurysouza.modulegraph" version "0.4.0"
}
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "dev.iurysouza:modulegraph:0.4.0"
    }
}

apply plugin: "dev.iurysouza.modulegraph"

Configuring the plugin

  moduleGraphConfig {
    readmePath = "./README.md"
    heading = '### Dependency Diagram'
    theme = Theme.NEUTRAL // optional
    orientation = Orientation.LEFT_TO_RIGHT // optional
    linkText = LinkText.NONE // optional
}

build.gradle.kts (Kotlin DSL)

Using the plugins DSL

plugins {
    id("dev.iurysouza.modulegraph") version "0.4.0"
}
buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("dev.iurysouza:modulegraph:0.4.0")
    }
}

apply(plugin = "dev.iurysouza:modulegraph")

Configuring the plugin

moduleGraphConfig {
    readmePath.set("./README.md")
    heading.set("### Dependency Diagram")
    theme.set(Theme.NEUTRAL) // optional
    orientation.set(Orientation.LEFT_TO_RIGHT) //optional
    linkText.set(LinkText.NONE) // optional
}

Configuration

To configure the Gradle Module Dependency Graph Plugin, you can set the following options:

  • readmePath: The path of the file where the dependency graph will be appended.
  • heading: The heading where the dependency graph will be appended.

Optional settings:

  • theme: The mermaid theme to be used for styling the graph. Default is NEUTRAL.
  • orientation: The orientation that the flowchart will have. Default is LEFT_TO_RIGHT.
  • linkText: Whether to add information as text on links in graph. Available values:
    • NONE: No text added. (Default.)
    • CONFIGURATION: The name of the configuration which the dependency belongs to (e.g. " implementation", "compileOnly", "jsMain").

Usage

Make sure you have a heading in your README with the same format as the one you set in the configuration, if not, the plugin will append it with the graph to the end of the file.

After that, just run the following command:

./gradlew createModuleGraph

Now, just look for the generated graph in your project's README file.

Example Diagram

You can expect the plugin to generate this kind of diagram after running the plugin:

%%{
  init: {
    'theme': 'neutral'
  }
}%%

graph LR
  subgraph app
    main
    playground
  end
  subgraph core
    common
    design-system
    footballdata
    reddit
  end
  subgraph features
    match-day
    match-thread
  end
  main --> match-thread
  main --> match-day
  main --> footballdata
  main --> reddit
  main --> design-system
  main --> common
  playground --> match-thread
  playground --> match-day
  playground --> footballdata
  playground --> reddit
  playground --> design-system
  playground --> common
  footballdata --> common
  reddit --> common
  match-day --> common
  match-day --> footballdata
  match-day --> design-system
  match-day --> reddit
  match-thread --> common
  match-thread --> footballdata
  match-thread --> design-system
  match-thread --> reddit

Contributing 🀝

Feel free to open an issue or submit a pull request for any bugs/improvements.

License πŸ“„

This template is licensed under the MIT License - see the License file for details.

About

A Gradle Plugin for visualizing your project structure powered by mermaidjs

https://plugins.gradle.org/plugin/dev.iurysouza.modulegraph

License:MIT License


Languages

Language:Kotlin 100.0%