Skip to content

Commit

Permalink
Update graphviz-java to 0.18.1 (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis authored Jun 4, 2022
1 parent 357789d commit 4b28fd7
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 139 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ repositories {
dependencies {
implementation localGroovy()
implementation gradleApi()
api "guru.nidi:graphviz-java:0.8.1"
api "guru.nidi:graphviz-java:0.18.1"

testImplementation 'junit:junit:4.13.2'
testImplementation "com.android.tools.build:gradle:7.0.4"
Expand All @@ -90,4 +90,5 @@ test {
testLogging {
exceptionFormat "full"
}
jvmArgs("-Xmx2048m")
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=vanniktech
POM_DEVELOPER_NAME=Niklas Baudy
POM_DEVELOPER_NAME=Niklas Baudy

org.gradle.jvmargs=-Xmx2048m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.vanniktech.dependency.graph.generator

import com.vanniktech.dependency.graph.generator.DependencyGraphGeneratorExtension.Generator
import guru.nidi.graphviz.attribute.Font
import guru.nidi.graphviz.attribute.Label
import guru.nidi.graphviz.attribute.Rank
import guru.nidi.graphviz.attribute.Rank.RankType
import guru.nidi.graphviz.attribute.Shape
import guru.nidi.graphviz.model.Factory.graph
import guru.nidi.graphviz.model.Factory.mutGraph
Expand Down Expand Up @@ -31,8 +31,6 @@ internal class DependencyGraphGenerator(
graph.graphAttrs().add(it)
}

graph.nodeAttrs().add(Font.name("Times New Roman"))

val projects = (if (project.subprojects.size > 0) project.subprojects else setOf(project))
.filter { generator.includeProject(it) }

Expand Down Expand Up @@ -67,7 +65,7 @@ internal class DependencyGraphGenerator(
graph.add(
graph()
.graphAttr()
.with(Rank.SAME)
.with(Rank.inSubgraph(RankType.SAME))
.with(*rootNodes.map { mutNode(it) }.toTypedArray())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import guru.nidi.graphviz.attribute.Color
import guru.nidi.graphviz.attribute.Font
import guru.nidi.graphviz.attribute.Label
import guru.nidi.graphviz.attribute.Rank
import guru.nidi.graphviz.attribute.Rank.RankType
import guru.nidi.graphviz.attribute.Shape
import guru.nidi.graphviz.attribute.Style
import guru.nidi.graphviz.model.Factory.graph
Expand Down Expand Up @@ -40,7 +41,7 @@ internal class ProjectDependencyGraphGenerator(

val graph = mutGraph().setDirected(true)
graph.graphAttrs().add(Label.of(project.name).locate(Label.Location.TOP), Font.size(DEFAULT_FONT_SIZE))
graph.nodeAttrs().add(Font.name("Times New Roman"), Style.FILLED)
graph.nodeAttrs().add(Style.FILLED)
projects.forEach { addNode(it, dependencies, graph) }
rankRootProjects(graph, projects, dependencies)
addDependencies(dependencies, graph)
Expand Down Expand Up @@ -72,7 +73,7 @@ internal class ProjectDependencyGraphGenerator(
graph.add(
graph()
.graphAttr()
.with(Rank.SAME)
.with(Rank.inSubgraph(RankType.SAME))
.with(*projects.filter { project -> dependencies.none { it.to == project } }.map { mutNode(it.path) }.toTypedArray())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ class DependencyGraphGeneratorPluginTest {
)

fun runBuild(): BuildResult {
return GradleRunner.create()
return GradleRunner.create().withDebug(true)
.withPluginClasspath()
.withGradleVersion(gradleVersion)
.withProjectDir(testProjectDir.root)
.withArguments("generateDependencyGraph", "generateProjectDependencyGraph")
.withArguments("generateDependencyGraph", "generateProjectDependencyGraph", "-Dorg.gradle.jvmargs=-Xmx2048m", "--stacktrace")
.build()
}

Expand All @@ -96,13 +96,14 @@ class DependencyGraphGeneratorPluginTest {
assertEquals(
"""
digraph "G" {
node ["fontname"="Times New Roman"]
"${testProjectDir.root.name}" ["shape"="rectangle","label"="${testProjectDir.root.name}"]
"orgjetbrainskotlinkotlinstdlib" ["shape"="rectangle","label"="kotlin-stdlib"]
"orgjetbrainsannotations" ["shape"="rectangle","label"="jetbrains-annotations"]
"ioreactivexrxjava2rxjava" ["shape"="rectangle","label"="rxjava"]
"orgreactivestreamsreactivestreams" ["shape"="rectangle","label"="reactive-streams"]
edge ["dir"="forward"]
"${testProjectDir.root.name}" ["label"="${testProjectDir.root.name}","shape"="rectangle"]
"orgjetbrainskotlinkotlinstdlib" ["label"="kotlin-stdlib","shape"="rectangle"]
"orgjetbrainsannotations" ["label"="jetbrains-annotations","shape"="rectangle"]
"ioreactivexrxjava2rxjava" ["label"="rxjava","shape"="rectangle"]
"orgreactivestreamsreactivestreams" ["label"="reactive-streams","shape"="rectangle"]
{
edge ["dir"="none"]
graph ["rank"="same"]
"${testProjectDir.root.name}"
}
Expand All @@ -122,9 +123,11 @@ class DependencyGraphGeneratorPluginTest {
assertEquals(
"""
digraph {
graph ["fontsize"="35","label"="${testProjectDir.root.name}","labelloc"="t"]
node ["fontname"="Times New Roman","style"="filled"]
edge ["dir"="forward"]
graph ["label"="${testProjectDir.root.name}","labelloc"="t","fontsize"="35"]
node ["style"="filled"]
{
edge ["dir"="none"]
graph ["rank"="same"]
}
}
Expand Down Expand Up @@ -244,11 +247,11 @@ class DependencyGraphGeneratorPluginTest {

val empty = testProjectDir.newFolder("empty").run { parentFile.name + name }

val result = GradleRunner.create()
val result = GradleRunner.create().withDebug(true)
.withPluginClasspath()
.withGradleVersion("7.4.2")
.withProjectDir(testProjectDir.root)
.withArguments("generateDependencyGraph", "generateProjectDependencyGraph", "app:generateProjectDependencyGraph")
.withArguments("generateDependencyGraph", "generateProjectDependencyGraph", "app:generateProjectDependencyGraph", "-Dorg.gradle.jvmargs=-Xmx2048m", "--stacktrace")
.build()

result.tasks.filter { it.path.contains("DependencyGraph") }.forEach {
Expand All @@ -261,17 +264,18 @@ class DependencyGraphGeneratorPluginTest {
assertEquals(
"""
digraph "G" {
node ["fontname"="Times New Roman"]
"$app" ["shape"="rectangle","label"="app"]
"$lib1" ["shape"="rectangle","label"="lib1"]
"$lib" ["shape"="rectangle","label"="lib"]
"ioreactivexrxjava2rxjava" ["shape"="rectangle","label"="rxjava"]
"orgreactivestreamsreactivestreams" ["shape"="rectangle","label"="reactive-streams"]
"orgjetbrainskotlinkotlinstdlib" ["shape"="rectangle","label"="kotlin-stdlib"]
"orgjetbrainsannotations" ["shape"="rectangle","label"="jetbrains-annotations"]
"$lib2" ["shape"="rectangle","label"="lib2"]
"$empty" ["shape"="rectangle","label"="empty"]
edge ["dir"="forward"]
"$app" ["label"="app","shape"="rectangle"]
"$lib1" ["label"="lib1","shape"="rectangle"]
"$lib" ["label"="lib","shape"="rectangle"]
"ioreactivexrxjava2rxjava" ["label"="rxjava","shape"="rectangle"]
"orgreactivestreamsreactivestreams" ["label"="reactive-streams","shape"="rectangle"]
"orgjetbrainskotlinkotlinstdlib" ["label"="kotlin-stdlib","shape"="rectangle"]
"orgjetbrainsannotations" ["label"="jetbrains-annotations","shape"="rectangle"]
"$lib2" ["label"="lib2","shape"="rectangle"]
"$empty" ["label"="empty","shape"="rectangle"]
{
edge ["dir"="none"]
graph ["rank"="same"]
"$app"
"$empty"
Expand All @@ -294,13 +298,15 @@ class DependencyGraphGeneratorPluginTest {

fun projectDependencyGraph(label: String) = """
digraph {
graph ["fontsize"="35","label"="$label","labelloc"="t"]
node ["fontname"="Times New Roman","style"="filled"]
":app" ["fillcolor"="#ff8a65","shape"="rectangle"]
edge ["dir"="forward"]
graph ["label"="$label","labelloc"="t","fontsize"="35"]
node ["style"="filled"]
":app" ["shape"="rectangle","fillcolor"="#ff8a65"]
":lib1" ["fillcolor"="#ff8a65"]
":lib" ["fillcolor"="#ff8a65"]
":lib2" ["fillcolor"="#ff8a65"]
{
edge ["dir"="none"]
graph ["rank"="same"]
":app"
}
Expand Down
Loading

0 comments on commit 4b28fd7

Please sign in to comment.