Skip to content

A Gradle plugin to automatically generate Entity-Relationship (ER) diagrams from Android Room database schema JSON files in Mermaid format.

License

Notifications You must be signed in to change notification settings

ntsk/room-schema-docs-gradle-plugin

Repository files navigation

Room Schema Docs Gradle Plugin

build Gradle Plugin Portal

A Gradle plugin to automatically generate Entity-Relationship (ER) diagrams in Mermaid format from Android Room database schema JSON files.

Features

  • Generates ER diagrams in Mermaid syntax based on Room schema JSON files.
  • Outputs diagrams embedded in Markdown files, making it easy to review schema relationships and manage database changes over time.

Output Example

When schema JSON files like sample/schemas exist, you can generate Markdown(Mermaid Syntax) documents like sample/schemas-docs.

Getting Started

Prerequisites

  • Android Room configured to export schemas.
  • Gradle 7.x or higher.

Installation

  1. Add the plugin to your build.gradle.kts:
plugins {
    id("jp.ntsk.room-schema-docs") version "1.1.0"
}
  1. Ensure Room's schema export is enabled by adding the following to your build.gradle.kts:
room {
    schemaDirectory("$projectDir/schemas")
}

refs. https://developer.android.com/training/data-storage/room/migrating-db-versions#set_schema_location_using_room_gradle_plugin

  1. Configure the plugin in your build.gradle.kts:
roomSchemaDocs {
    schemaDir = "$projectDir/schemas"
    outputDir = "$projectDir/schemas-docs"
}

Generating ER Diagrams

After setting up, run the following command to generate ER diagrams:

./gradlew generateRoomSchemaDocs

Output Example

For a directory structure like:

schemas/
├── <YOUR_PACKAGE_NAME>/
│   └── 1.json

The plugin will generate:

schemas-docs/
├── <YOUR_PACKAGE_NAME>/
│   └── 1.md

About

A Gradle plugin to automatically generate Entity-Relationship (ER) diagrams from Android Room database schema JSON files in Mermaid format.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages