Code Monkey home page Code Monkey logo

dependency-graph-plugin's Introduction

dependency-graph-plugin

A simple Gradle plugin that shows the dependency graph of the project.

preview


Download maven-central

use 1.1.0 version!

plugins {
    id("land.sungbin.dependency.graph.plugin") version "$version"
}

Usage

  1. Download graphviz.
  2. Setting dependencyGraphConfig.
  3. Run ./gradlew dependencyGraph.
dependencyGraphConfig {
    /**
     * The path where the dot file of the graph will be generated.
     * The png of the graph is generated along this path, too.
     *
     * Default is "generated/dependency-graph/project.dot".
     */
    dotFilePath = "generated/dependency-graph/project.dot"

    /**
     * Whether to automatically delete the dot file after
     * the png is created from the dot file of the graph.
     *
     * Default is `true`.
     */
    autoDeleteDotFile = true

    /**
     * Name to be displayed at the top of the graph.
     *
     * Default is `null`.
     * `null` means: `${project.rootProject.name}`
     */
    projectName = null // String type 

    /**
     * The default **Hex** color to use when graphing uncolored dependencies.
     *
     * Defaults to `#eeeeee`, skipped graphing if `null` is provided.
     */
    defaultDependencyColor = "#eeeeee" // String? type

    /**
     * The format in which the graph image will be generated.
     *
     * Default is [OutputFormat.PNG].
     */
    outputFormat = OutputFormat.PNG // OutputFormat Type. Available: PNG, SVG, JPG

    /**
     * **[REQUIRE]** Add dependency information to the graph.
     *
     * @param builder The lambda that calculates the dependency information.
     *  - project: Instances of the Project to compute information
     *
     * @return A dependency information object. See [DependencyInfo].
     */
    fun dependencyBuilder(builder: (project: Project) -> DependencyInfo?)
}

/**
 * A dependency information object.
 *
 * @param color **Hex** color of the dependency
 * @param isBoxShape Whether that dependency will be displayed as a rectangle on the graph.
 * The default value is `false`, and in case of `false`, it is displayed as an oval.
 */
data class DependencyInfo(
    val color: String,
    val isBoxShape: Boolean = false,
)

Example

You can check sample project at here.

// example 1
dependencyGraphConfigs {
    dependencyBuilder { project ->
        with(project.plugins) {
            when {
                hasPlugin("project.three") -> DependencyInfo("#81d4fa", isBoxShape = true)
                hasPlugin("project.two") -> DependencyInfo("#ffc9ba")
                hasPlugin("project.one") -> DependencyInfo("#fcb96a")
                else -> null
            }
        }
    }
}

// example 2
dependencyGraphConfigs {
    dotFilePath = "assets/dependency-graph/project.dot"
    
    dependencyBuilder { project ->
        with(project) {
            when {
                plugins.hasPlugin(PluginEnum.AndroidApplication) -> DependencyInfo("#baffc9", isBoxShape = true)
                plugins.hasPlugin(PluginEnum.AndroidDfm) -> DependencyInfo("#c9baff")
                plugins.hasPlugin(PluginEnum.JavaLibrary) -> DependencyInfo("#ffc9ba")
                name.startsWith(UtilModulePrefix) -> DependencyInfo("#ffebba")
                name.startsWith(FeatureModulePrefix) && !name.contains(OnlyUiFeatureModulePrefix) -> DependencyInfo("#81d4fa")
                name.startsWith(UiFeatureModulePrefix) -> DependencyInfo("#00aeff")
                plugins.hasPlugin(PluginEnum.AndroidLibrary) -> DependencyInfo("#fcb96a")
                else -> null
            }
        }
    }
}

Credit

The original implementation is by JakeWharton.

License

This project is licensed under the MIT License. Please refer to the LICENSE file for details.

dependency-graph-plugin's People

Contributors

jisungbin avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dependency-graph-plugin's Issues

TODO: Configuration Cache

Configuration Cache is not currently supported. Please add the options below as a workaround.

tasks.matching { task ->
    task.name.contains("dependencyGraph")
}.configureEach {
    notCompatibleWithConfigurationCache("https://github.com/jisungbin/dependency-graph-plugin/issues/8")
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

Renovate tried to run on this repository, but found these problems.

  • WARN: RepoCacheS3.read() - failure

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
  • org.jetbrains.kotlin.jvm 1.8.21
  • com.vanniktech.maven.publish 0.25.2
  • io.kotest:kotest-runner-junit5 5.6.1
sample/settings.gradle.kts
sample/build.gradle.kts
  • org.jetbrains.kotlin.jvm 1.8.21
  • land.sungbin.dependency.graph.plugin 1.1.0
sample/local-plugins/settings.gradle.kts
sample/local-plugins/build.gradle.kts
sample/project-one/build.gradle.kts
sample/project-three/build.gradle.kts
sample/project-two/build.gradle.kts
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.