Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cacheinvalidationindex/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gradlePlugin {

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(libs.graphviz.java)
implementation(libs.jgrapht.core)
implementation(libs.jgrapht.io)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class CacheInvalidationIndexTask @Inject constructor(
val affectedSubgraphs = affectedSubgraphs(dag)
graphVizWriter.writeGraph(
graph = affectedSubgraphs.find { it.node == project.path }!!.affectedDag,
file = project.file("build/graph.dot")
file = project.file("build/cacheinvalidationindex/dependency_graph.png")
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.ivanalvarado.cacheinvalidationindex.writer

import com.ivanalvarado.cacheinvalidationindex.domain.model.DependencyEdge
import guru.nidi.graphviz.engine.Format
import guru.nidi.graphviz.engine.Graphviz
import org.jgrapht.graph.AbstractGraph
import org.jgrapht.nio.DefaultAttribute
import org.jgrapht.nio.dot.DOTExporter
import java.io.File
import java.io.StringWriter

class GraphVizWriter {

Expand All @@ -25,8 +28,14 @@ class GraphVizWriter {
}
}

val writer = StringWriter()
exporter.exportGraph(graph, writer)
val dotString = writer.toString()

file.delete()
exporter.exportGraph(graph, file)
Graphviz.fromString(dotString)
.render(Format.PNG)
.toFile(file)
}

private fun String.sanitize(): String {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[versions]
graphviz-java = "0.18.1"
jetbrainsKotlinJvm = "1.9.24"
jgrapht = "1.5.1"
junit = "4.13.2"
truth = "1.4.4"

[libraries]
graphviz-java = { group = "guru.nidi", name = "graphviz-java", version.ref = "graphviz-java" }
jgrapht-core = { group = "org.jgrapht", name = "jgrapht-core", version.ref = "jgrapht" }
jgrapht-io = { group = "org.jgrapht", name = "jgrapht-io", version.ref = "jgrapht" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand Down