├── gradle.properties ├── settings.gradle.kts ├── src └── main │ └── kotlin │ └── com │ └── github │ └── ivancarras │ └── graphfity │ └── plugin │ ├── model │ ├── datastructures │ │ ├── Node.kt │ │ ├── Edge.kt │ │ └── AdjacencyList.kt │ ├── ProjectModuleEdge.kt │ ├── ProjectModuleNode.kt │ ├── ProjectModuleData.kt │ └── ProjectModuleAdjacencyList.kt │ ├── main │ ├── GraphfityPlugin.kt │ └── GraphfityPluginExtension.kt │ ├── mapper │ ├── ProjectGraphToDotMappers.kt │ └── GradleProjectToProjectGraphMapper.kt │ └── task │ └── GraphfityTask.kt ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── .gitignore ├── README.md └── LICENSE /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "graphfity-plugin" -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/datastructures/Node.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model.datastructures 2 | 3 | data class Node(val id: String, val data: T) 4 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/datastructures/Edge.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model.datastructures 2 | 3 | data class Edge( 4 | val source: Node, 5 | val destination: Node, 6 | ) 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/ProjectModuleEdge.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model 2 | 3 | import com.github.ivancarras.graphfity.plugin.model.datastructures.Edge 4 | 5 | typealias ProjectModuleEdge = Edge 6 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/ProjectModuleNode.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model 2 | 3 | import com.github.ivancarras.graphfity.plugin.model.datastructures.Node 4 | 5 | typealias ProjectModuleNode = Node 6 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/ProjectModuleData.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model 2 | 3 | data class ProjectModuleData(val path: String, val nodeType: NodeType, val level: Int) { 4 | data class NodeType( 5 | val name: String, 6 | val regex: String, 7 | val isEnabled: Boolean, 8 | val shape: String, 9 | val fillColor: String, 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.jar 3 | *.war 4 | *.ear 5 | # generated files 6 | bin/** 7 | gen/** 8 | # project based files 9 | .idea/ 10 | *.iml 11 | *.ipr 12 | *.iws 13 | .gradletasknamecache 14 | .gradle/ 15 | build/ 16 | bin/ 17 | 18 | .gradle 19 | **/build/ 20 | !src/**/build/ 21 | 22 | **/gradlew.bat 23 | **/gradlew 24 | 25 | # Ignore Gradle GUI config 26 | gradle-app.setting 27 | 28 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 29 | gradle-wrapper.jar 30 | path/to/standalone/plugin/project/ 31 | /local.properties -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/main/GraphfityPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.main 2 | 3 | import com.github.ivancarras.graphfity.plugin.task.GraphfityTask 4 | import org.gradle.api.Plugin 5 | import org.gradle.api.Project 6 | 7 | class GraphfityPlugin : Plugin { 8 | override fun apply(project: Project) { 9 | val extension = project.extensions.create("graphfityExtension", GraphfityPluginExtension::class.java) 10 | project.tasks.create("graphfity", GraphfityTask::class.java) { 11 | it.graphImagePathProperty.set(extension.graphImagePath) 12 | it.projectRootNameProperty.set(extension.projectRootName) 13 | it.nodeTypesPathProperty.set(extension.nodeTypesPath) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/datastructures/AdjacencyList.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model.datastructures 2 | 3 | open class AdjacencyList { 4 | 5 | protected val adjacencyMap = mutableMapOf, ArrayList>>() 6 | 7 | val nodes: List> 8 | get() = adjacencyMap.keys.toList() 9 | 10 | val edges: List> 11 | get() = adjacencyMap.values.flatten().toList() 12 | 13 | fun addNode(node: Node): Node { 14 | adjacencyMap[node] = arrayListOf() 15 | return node 16 | } 17 | 18 | open fun addDirectedEdge(source: Node, destination: Node) { 19 | val edge = Edge(source = source, destination = destination) 20 | adjacencyMap[source]?.add(edge) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/main/GraphfityPluginExtension.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.main 2 | 3 | import org.gradle.api.provider.Property 4 | 5 | @Suppress("LeakingThis") 6 | abstract class GraphfityPluginExtension { 7 | abstract val nodeTypesPath: Property 8 | abstract val graphImagePath: Property 9 | abstract val projectRootName: Property 10 | 11 | init { 12 | graphImagePath.convention(DEFAULT_GRAPH_IMAGE_PATH) 13 | projectRootName.convention(DEFAULT_PROJECT_ROOT_NAME) 14 | nodeTypesPath.convention(DEFAULT_NODE_TYPES_PATH) 15 | } 16 | 17 | companion object { 18 | private const val DEFAULT_GRAPH_IMAGE_PATH = "./graphfity/" 19 | private const val DEFAULT_PROJECT_ROOT_NAME = ":app" 20 | private const val DEFAULT_NODE_TYPES_PATH = "./graphfity/" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/mapper/ProjectGraphToDotMappers.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.mapper 2 | 3 | import com.github.ivancarras.graphfity.plugin.model.ProjectGraph 4 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleData 5 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleEdge 6 | import com.github.ivancarras.graphfity.plugin.model.datastructures.Node 7 | 8 | private const val RANK_SEP = 1.2 9 | 10 | fun ProjectGraph.toDot(): String = graphDot { 11 | nodesDot(this@toDot) 12 | edgesDot(this@toDot) 13 | ranksDot(this@toDot) 14 | } 15 | 16 | private fun StringBuilder.nodesDot( 17 | adjacencyList: ProjectGraph, 18 | ) { 19 | adjacencyList.nodes.forEach { appendLine(it.toDot()) } 20 | } 21 | 22 | private fun StringBuilder.edgesDot( 23 | adjacencyList: ProjectGraph, 24 | ) { 25 | adjacencyList.edges.forEach { appendLine(it.toDot()) } 26 | } 27 | 28 | private fun StringBuilder.ranksDot( 29 | adjacencyList: ProjectGraph, 30 | ) { 31 | adjacencyList.nodes.groupBy { it.data.level }.forEach { 32 | append(" {rank = same;") 33 | it.value.forEach { node -> 34 | append(" \"${node.data.path}\";") 35 | } 36 | appendLine("}") 37 | } 38 | } 39 | 40 | private fun graphDot(content: StringBuilder.() -> Unit): String = buildString { 41 | appendLine("digraph {") 42 | appendLine(" graph [ranksep=$RANK_SEP];") 43 | content() 44 | append("}") 45 | } 46 | 47 | private fun Node.toDot(): String = buildString { 48 | appendLine(" node [style=filled, shape=${data.nodeType.shape} fillcolor=\"${data.nodeType.fillColor}\"];") 49 | append(" \"${data.path}\"") 50 | } 51 | 52 | private fun ProjectModuleEdge.toDot(): String = buildString { 53 | append(" \"${source.data.path}\" -> \"${destination.data.path}\";") 54 | } 55 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/model/ProjectModuleAdjacencyList.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.model 2 | 3 | import com.github.ivancarras.graphfity.plugin.model.datastructures.AdjacencyList 4 | import com.github.ivancarras.graphfity.plugin.model.datastructures.Edge 5 | import com.github.ivancarras.graphfity.plugin.model.datastructures.Node 6 | 7 | class ProjectGraph : AdjacencyList() { 8 | 9 | override fun addDirectedEdge(source: Node, destination: Node) { 10 | val edge = Edge(source = source, destination = destination) 11 | if (adjacencyMap[source]?.contains(edge) == false) { 12 | super.addDirectedEdge(source = source, destination = destination) 13 | } 14 | } 15 | 16 | fun updateNode(node: Node) { 17 | val updatedAdjacencyMap = ProjectGraph().adjacencyMap 18 | adjacencyMap.forEach { entry -> 19 | val updatedKey = if (entry.key.id == node.id) { 20 | node 21 | } else { 22 | entry.key 23 | } 24 | val updatedValue = ArrayList(entry.value.map { edge -> 25 | val updatedSource = if (edge.source.id == node.id) { 26 | node 27 | } else { 28 | edge.source 29 | } 30 | val updatedDestination = if (edge.destination.id == node.id) { 31 | node 32 | } else { 33 | edge.destination 34 | } 35 | Edge(source = updatedSource, destination = updatedDestination) 36 | }) 37 | updatedAdjacencyMap[updatedKey] = updatedValue 38 | } 39 | adjacencyMap.clear() 40 | adjacencyMap.putAll(updatedAdjacencyMap) 41 | } 42 | 43 | fun contains(id: String): Boolean = 44 | nodes.any { it.id == id } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/task/GraphfityTask.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.task 2 | 3 | import com.github.ivancarras.graphfity.plugin.mapper.toDot 4 | import com.github.ivancarras.graphfity.plugin.mapper.toProjectGraph 5 | import com.github.ivancarras.graphfity.plugin.model.ProjectGraph 6 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleData.NodeType 7 | import groovy.json.JsonSlurper 8 | import java.io.BufferedWriter 9 | import java.io.File 10 | import java.io.IOException 11 | import java.io.OutputStreamWriter 12 | import org.gradle.api.DefaultTask 13 | import org.gradle.api.Project 14 | import org.gradle.api.provider.Property 15 | import org.gradle.api.tasks.Input 16 | import org.gradle.api.tasks.TaskAction 17 | 18 | abstract class GraphfityTask : DefaultTask() { 19 | @Input 20 | val nodeTypesPathProperty: Property = project.objects.property(String::class.java) 21 | 22 | @Input 23 | val graphImagePathProperty: Property = project.objects.property(String::class.java) 24 | 25 | @Input 26 | val projectRootNameProperty: Property = project.objects.property(String::class.java) 27 | 28 | private val nodeTypesPath: String by lazy { nodeTypesPathProperty.get() } 29 | private val graphFileImagePath: String by lazy { graphImagePathProperty.get() } 30 | private val projectRootName: String by lazy { projectRootNameProperty.get() } 31 | private val nodeTypes: Set by lazy { readNodeTypesFile(nodeTypesPath) } 32 | 33 | @TaskAction 34 | fun graphfity() { 35 | val rootProject = getRootProject(projectRootName) 36 | val adjacencyList: ProjectGraph = rootProject.toProjectGraph(nodeTypes = nodeTypes) 37 | val dot = adjacencyList.toDot() 38 | generateGraphFile(dot = dot) 39 | } 40 | 41 | private fun getRootProject(projectRootName: String): Project { 42 | return requireNotNull( 43 | project.findProject(projectRootName) 44 | ) { 45 | "The property provided as projectRootPath: $projectRootName does not correspond to any project" 46 | } 47 | } 48 | 49 | private fun readNodeTypesFile(nodeTypesPath: String): Set { 50 | val jsonFile = File(nodeTypesPath) 51 | val jsonObjects = JsonSlurper().parseText(jsonFile.readText()) 52 | return if (jsonObjects is List<*>) { 53 | jsonObjects.fold(setOf()) { acc, item -> 54 | if (item is Map<*, *>) { 55 | acc + NodeType( 56 | name = item["name"] as String, 57 | regex = item["regex"] as String, 58 | isEnabled = item["isEnabled"] as Boolean, 59 | shape = item["shape"] as String, 60 | fillColor = item["fillColor"] as String, 61 | ) 62 | } else { 63 | acc 64 | } 65 | } 66 | } else { 67 | error("Malformed json file") 68 | } 69 | } 70 | 71 | private fun generateGraphFile(dot: String) { 72 | try { 73 | val fullImagepath = graphFileImagePath + GRAPH_FILE_NAME 74 | val process = ProcessBuilder("dot", "-Tpng", "-o", fullImagepath) 75 | .redirectOutput(ProcessBuilder.Redirect.PIPE) 76 | .redirectError(ProcessBuilder.Redirect.PIPE) 77 | .start() 78 | 79 | BufferedWriter(OutputStreamWriter(process.outputStream)).use { writer -> 80 | writer.write(dot) 81 | writer.flush() 82 | } 83 | 84 | val exitCode = process.waitFor() 85 | if (exitCode != 0) { 86 | throw RuntimeException(process.errorStream.bufferedReader().readText()) 87 | } else { 88 | println("Graph successfully created at $fullImagepath") 89 | } 90 | } catch (e: IOException) { 91 | throw RuntimeException("Error executing dot command", e) 92 | } 93 | } 94 | 95 | companion object { 96 | private const val GRAPH_FILE_NAME = "graph.png" 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/ivancarras/graphfity/plugin/mapper/GradleProjectToProjectGraphMapper.kt: -------------------------------------------------------------------------------- 1 | package com.github.ivancarras.graphfity.plugin.mapper 2 | 3 | import com.github.ivancarras.graphfity.plugin.model.ProjectGraph 4 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleData 5 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleData.NodeType 6 | import com.github.ivancarras.graphfity.plugin.model.ProjectModuleNode 7 | import org.gradle.api.Project 8 | import org.gradle.api.artifacts.ProjectDependency 9 | import org.gradle.util.GradleVersion 10 | 11 | private const val ROOT_LEVEL = 0 12 | 13 | fun Project.toRootNode(nodeTypes: Set): ProjectModuleNode { 14 | val rootProjectModuleData = buildProjectModuleData( 15 | path = path, 16 | nodeTypes = nodeTypes, 17 | level = ROOT_LEVEL, 18 | ) ?: throw IllegalArgumentException("Root project path does not match any node type") 19 | return ProjectModuleNode(id = rootProjectModuleData.path, data = rootProjectModuleData) 20 | } 21 | 22 | fun Project.toProjectGraph(nodeTypes: Set): ProjectGraph { 23 | val adjacencyList = ProjectGraph() 24 | val rootNode = project.toRootNode(nodeTypes) 25 | adjacencyList.addNode(rootNode) 26 | addChildNodesForProjectDependencies( 27 | project = project, 28 | parentNode = rootNode, 29 | adjacencyList = adjacencyList, 30 | nodeTypes = nodeTypes, 31 | parentLevel = rootNode.data.level, 32 | ) 33 | return adjacencyList 34 | } 35 | 36 | 37 | private fun addChildNodesForProjectDependencies( 38 | parentNode: ProjectModuleNode, 39 | project: Project, 40 | nodeTypes: Set, 41 | adjacencyList: ProjectGraph, 42 | parentLevel: Int, 43 | ) { 44 | project.configurations 45 | .forEach { config -> 46 | config.dependencies 47 | .withType(ProjectDependency::class.java) 48 | .mapToProject(project) 49 | .filterNot { it.path == project.path } 50 | .forEach { childProject -> 51 | val childLevel = parentLevel + 1 52 | buildProjectModuleData( 53 | path = childProject.path, 54 | nodeTypes = nodeTypes, 55 | level = childLevel, 56 | )?.let { dependencyProjectNodeData -> 57 | val childNode = 58 | ProjectModuleNode(id = dependencyProjectNodeData.path, data = dependencyProjectNodeData) 59 | val isChildNodePresent = adjacencyList.contains(id = childNode.id) 60 | if (!isChildNodePresent) { 61 | adjacencyList.addNode(childNode) 62 | } 63 | adjacencyList.addDirectedEdge(source = parentNode, destination = childNode) 64 | 65 | // To rank correctly the child level, if we find a new dependency with a higher level 66 | // that the previously defined we update the node level 67 | val isNeededToUpdateChildNodeLevel = isChildNodePresent && childLevel > 68 | (adjacencyList.nodes.find { it.id == childNode.id }?.data?.level ?: Int.MAX_VALUE) 69 | if (isNeededToUpdateChildNodeLevel) { 70 | adjacencyList.updateNode(childNode) 71 | } 72 | 73 | if (!isChildNodePresent) { 74 | addChildNodesForProjectDependencies( 75 | parentNode = childNode, 76 | project = childProject, 77 | adjacencyList = adjacencyList, 78 | nodeTypes = nodeTypes, 79 | parentLevel = childNode.data.level, 80 | ) 81 | } 82 | } 83 | } 84 | } 85 | } 86 | 87 | 88 | @Suppress("deprecation") 89 | private fun Iterable.mapToProject(project: Project): List = map { 90 | // https://docs.gradle.org/8.11/release-notes.html 91 | // https://github.com/gradle/gradle/issues/30992 92 | // path attribute starts to be supported on Gradle 8.11 so we need to check the version before using it 93 | if (GradleVersion.current() > GradleVersion.version("8.11")) { 94 | project.project(it.path) 95 | } else { 96 | it.dependencyProject 97 | } 98 | } 99 | 100 | fun buildProjectModuleData( 101 | path: String, 102 | nodeTypes: Set, 103 | level: Int, 104 | ): ProjectModuleData? = 105 | nodeTypes.find { nodeType -> 106 | nodeType.regex.toRegex().matches(path) && nodeType.isEnabled 107 | }?.let { nodeType -> 108 | ProjectModuleData(path = path, nodeType = nodeType, level = level) 109 | } 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | 5 | 6 | 7 |

8 | 9 |

10 | Graphfity creates a dependency nodes diagram graph about your internal modules dependencies, specially useful if you are developing a multi-module application 11 |
12 |
13 | View Demo 14 | · 15 | Report Bug 16 | · 17 | Request Feature 18 |

19 |
20 |

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |

40 | 41 |
42 | 43 | 44 | 45 |
46 |

Table of Contents

47 |
    48 |
  1. 49 | About The Project 50 | 53 |
  2. 54 |
  3. 55 | Getting Started 56 | 61 |
  4. 62 |
  5. Usage
  6. 63 |
  7. Roadmap
  8. 64 |
  9. Contributing
  10. 65 |
  11. License
  12. 66 |
  13. Contact
  14. 67 |
68 |
69 | 70 | 71 | 72 | 73 | 74 | ## About The Project 75 | 76 | ![product-image](https://user-images.githubusercontent.com/23535893/131650974-228a131e-81b1-40cd-b2f9-fe6d41777d23.png) 77 | 78 | As a software engineer, you should know how difficult is to maintain a project without a previous initial good 79 | architecture. The project scales, new libraries, new features, new dependencies between the internal modules 80 | are added... 81 | 82 | The purpose of this plugin is help to visualize all the project dependencies between the internal modules, as the 83 | projects grows, having of this way a main screenshot of all the features, libraries, core modules, components, or 84 | whatever kind of module you want to analise in your project. 85 | 86 | ### Built With 87 | 88 | * [Graphviz](https://graphviz.org/) Graph visualization software 89 | * [Kotlin-DSL](https://docs.gradle.org/current/userguide/kotlin_dsl.html) An alternative to the traditional Groovy DSL 90 | using a modern language as Kotlin 91 | * [Kotlin](https://kotlinlang.org/) The natural Java evolution, a modern, concise and save programming language 92 | 93 | 94 | 95 | ## Getting Started 96 | 97 | ### Prerequisites 98 | 99 | **Graphviz setup** full guide: https://graphviz.org/download/ 100 | 101 | #### Mac 🍏 102 | 103 | ###### Option #1 104 | 105 | ```sh 106 | sudo port install graphviz 107 | ``` 108 | 109 | ###### Option #2 110 | 111 | ```sh 112 | brew install graphviz 113 | ``` 114 | 115 | #### Windows 116 | 117 | ###### Option #1 118 | 119 | ```sh 120 | winget install graphviz 121 | ``` 122 | 123 | ###### Option #2 124 | 125 | ```sh 126 | choco install graphviz 127 | ``` 128 | 129 | #### Linux 🐧 130 | 131 | ###### Option #1 132 | 133 | ```sh 134 | sudo apt install graphviz 135 | ``` 136 | 137 | ###### Option #2 138 | 139 | ``` 140 | sudo yum install graphviz 141 | ``` 142 | 143 | ###### Option #3 144 | 145 | ``` 146 | sudo apt install graphviz 147 | ``` 148 | 149 | ### Installation 150 | 151 | **Groovy DSL** 152 | 153 | *root build.gradle* 154 | 155 | ```groovy 156 | // Using the plugins DSL 157 | plugins { 158 | id "com.github.ivancarras.graphfity" version "1.1.0" 159 | } 160 | ``` 161 | 162 | ``` groovy 163 | // Using legacy plugin application 164 | buildscript { 165 | repositories { 166 | maven { 167 | url "https://plugins.gradle.org/m2/" 168 | } 169 | } 170 | dependencies { 171 | classpath "com.github.ivancarras:graphfity-plugin:1.1.0" 172 | } 173 | } 174 | apply plugin: com.github.ivancarras.graphfity.plugin.main.GraphfityPlugin 175 | ``` 176 | 177 | **Kotlin DSL** 178 | 179 | *root build.gradle.kts* 180 | 181 | ``` kotlin 182 | // Using the plugins DSL 183 | plugins { 184 | id("com.github.ivancarras.graphfity") version "1.1.0" 185 | } 186 | ``` 187 | 188 | 189 | 190 | ```kotlin 191 | // Using legacy plugin application 192 | buildscript { 193 | repositories { 194 | maven { 195 | url = uri("https://plugins.gradle.org/m2/") 196 | } 197 | } 198 | dependencies { 199 | classpath("com.github.ivancarras:graphfity-plugin:1.1.0") 200 | } 201 | } 202 | 203 | apply(plugin = "com.github.ivancarras.graphfity") 204 | 205 | ``` 206 | 207 | ### Plugin configuration 208 | 209 | The plugin admits 3 configuration properties: 210 | 211 | - **nodeTypesPath** (mandatory): this is the path for your json node types configuration file (explanation below) 212 | - **projectRootName** (optional): start point from the task draws the dependencies, the default value is the ":app" 213 | module 214 | - **graphImagePath** (optional): path where your graph image will be placed 215 | 216 | #### NodeTypes.json 217 | 218 | This is the file used to establish the different nodeTypes of your project a perfect example could be a project divided 219 | into: 220 | 221 | - App 222 | - Features 223 | - Components 224 | - Libraries 225 | - Core 226 | 227 |

228 | 229 |

230 | 231 | *nodeTypes.json* 232 | 233 | ``` json 234 | [ 235 | { 236 | "name": "App", 237 | "regex": "^:app$", 238 | "isEnabled": true, 239 | "shape": "box3d", 240 | "fillColor": "#BAFFC9" 241 | }, 242 | { 243 | "name": "Feature", 244 | "regex": "^.*feature.*$", 245 | "isEnabled": true, 246 | "shape": "tab", 247 | "fillColor": "#E6F98A" 248 | }, 249 | { 250 | "name": "Component", 251 | "regex": "^.*component.*$", 252 | "isEnabled": true , 253 | "shape": "component", 254 | "fillColor": "#8AD8F9" 255 | }, 256 | { 257 | "name": "Libraries", 258 | "regex": "^.*libraries.*$", 259 | "isEnabled": true, 260 | "shape": "cylinder", 261 | "fillColor": "#FFACFA" 262 | }, 263 | { 264 | "name": "Core", 265 | "regex": "^.*core.*$", 266 | "isEnabled": true, 267 | "shape": "hexagon", 268 | "fillColor": "#D5625A" 269 | } 270 | ] 271 | 272 | ``` 273 | 274 | **Node explanation** 275 | 276 | ``` json 277 | { 278 | "name": "App", //Node name 279 | "regex": "^:app$", //This regex corresponds to the modules which will be draw as this node type 280 | "isEnabled": true, //Enable o disable the visualization of this node 281 | "shape": "box3d", // Graphviz node shape you can choose another one using: https://graphviz.org/doc/info/shapes.html 282 | "fillColor": "#BAFFC9"//Hexadecimal color for these nodes 283 | } 284 | ``` 285 | 286 | **Copy this initial configuration file in an accessible path in your project. (the root path is perfect)** 287 | 288 | Now is time to configure the plugin: 289 | 290 | **Groovy DSL** 291 | 292 | *root build.gradle.kts* 293 | ``` groovy 294 | graphfityExtension { 295 | nodeTypesPath = "" //(mandatory) Examples: graphfityConfig/nodesTypes.json establish the route to your nodeTypes.json 296 | projectRootName = "" //(optional) Examples: ":app", ":feature:wishlist"... is up to you 297 | graphImagePath = "" //(optional)the folder where will be placed your graph.png image 298 | } 299 | ``` 300 | 301 | **Kotlin DSL** 302 | 303 | *root build.gradle.kts* 304 | ``` kotlin 305 | configure { 306 | nodeTypesPath.set("") //(mandatory) Examples: graphfityConfig/nodesTypes.json establish the route to your nodeTypes.json 307 | projectRootName.set("") //(optional) Examples: ":app", ":feature:wishlist"... is up to you 308 | graphImagePath.set("") //(optional)the folder where will be placed your graph.png image 309 | } 310 | ``` 311 | 312 | ## Usage 313 | 314 | When your configuration is done now you can execute: 315 | 316 | #### Mac 🍏 & Linux 🐧 317 | 318 | ```shell 319 | ./gradlew graphfity 320 | ``` 321 | 322 | #### Windows 🪟 323 | 324 | ```shell 325 | gradle graphfity 326 | ``` 327 | 328 | The graph is going to be generated in the respective **graphImagePath** defined in the configuration 329 | 330 | ## Roadmap 331 | 332 | See the [open issues](https://github.com/ivancarras/graphfity/issues) for a list of proposed features (and known issues) 333 | 334 | 335 | 336 | 337 | ## Contributing 338 | 339 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any 340 | contributions you make are **greatly appreciated**. 341 | 342 | 1. Fork the Project 343 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 344 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 345 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 346 | 5. Open a Pull Request 347 | 348 | 349 | 350 | ## License 351 | 352 | Distributed under the Apache License. See `LICENSE` for more information. 353 | 354 | 355 | 356 | 357 | ## Contact 358 | 359 | [![LinkedIn][linkedin-shield]][linkedin-url] 360 | 361 | ivan.carrasco.dev@gmail.com 362 | 363 | 364 | 365 | 366 | 367 | [linkedin-shield]: https://img.shields.io/badge/LinkedIn-0077B5?logo=linkedin&logoColor=white 368 | 369 | [linkedin-url]: https://www.linkedin.com/in/iv%C3%A1n-carrasco-alonso-22a852119/ 370 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------