Skip to content

Generate class structure diagrams out of kotlin code

License

Notifications You must be signed in to change notification settings

janphkre/class_relations

Repository files navigation

class_relations

Class_relations aims to provide a generator for class relations on a package level.

A simple example can be found in the tests:

Usage

Like any gradle plugin, class_relations is also defined as a plugin:

pluginManagement {
    repositories {
        maven {
            url = uri("https://jitpack.io")
            content {
                includeGroupAndSubgroups("com.github")
            }
        }
    }
    resolutionStrategy {
        eachPlugin {
            requested.apply {
                if ("$id".startsWith("com.github.")) {
                    useModule("$id:gradle_plugin:$version")
                }
            }
        }
    }
}

plugins {
    id("com.github.janphkre.class_relations") version "$libs.versions.classRelationsPlugin"
}


pumlGenerate {
    destination = "build/generated/puml_class_relations"
    sources = ["src/main/kotlin"]
    projectPackagePrefix = "readme.example"
    selfColor = "#00FF00"
    spaceCount = 4
    generatedFileName = "class_relations.puml"
    filters = [
            "*",
            "**.*Module"
    ]
}

The task generateClassRelationsPuml can be executed to generate the diagrams.

Multi module projects

If you want to use this plugin in a multi module project a different approach to the setup is needed in the root project. Each submodule will then take on the configuration of the root project and use the detected package name of the sub project. All sub projects will be linked against each other.

pluginManagement {
    repositories {
        maven {
            url = uri("https://jitpack.io")
            content {
                includeGroupAndSubgroups("com.github")
            }
        }
    }
    resolutionStrategy {
        eachPlugin {
            requested.apply {
                if ("$id".startsWith("com.github.")) {
                    useModule("$id:gradle_plugin:$version")
                }
            }
        }
    }
}

plugins {
    id("com.github.janphkre.class_relations.grouping") version "$libs.versions.classRelationsPlugin"
}


pumlGenerateAll {
    destination = "build/generated/puml_class_relations"
    sources = ["src/main/java"]
    projectBasePrefix = "readme.example"
    selfColor = "#00FF00"
    spaceCount = 4
    generatedFileName = "class_relations.puml"
    filters = [
            "*",
            "**.*Module"
    ]
}

License

This project is licensed under the Apache License 2.0, see here.

About

Generate class structure diagrams out of kotlin code

Topics

Resources

License

Stars

Watchers

Forks

Languages