Skip to content

Commit 4f700ec

Browse files
RBusarowkodiakhq[bot]
authored andcommitted
fix relative paths for custom graph report directory
fixes #575
1 parent d09275f commit 4f700ec

File tree

7 files changed

+203
-62
lines changed

7 files changed

+203
-62
lines changed

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ moduleCheck {
4949
checks {
5050
sortDependencies = true
5151
}
52+
reports {
53+
graphs {
54+
enabled = true
55+
outputDir = File(buildDir, "depths").path
56+
}
57+
}
5258
}
5359

5460
tasks.named("ktlintFormat") {

modulecheck-core/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ dependencies {
5757
testImplementation(project(path = ":modulecheck-config:fake"))
5858
testImplementation(project(path = ":modulecheck-internal-testing"))
5959
testImplementation(project(path = ":modulecheck-parsing:source:api"))
60-
testImplementation(project(path = ":modulecheck-project:api"))
6160
testImplementation(project(path = ":modulecheck-project:testing"))
6261
testImplementation(project(path = ":modulecheck-runtime:testing"))
6362
testImplementation(project(path = ":modulecheck-utils"))

modulecheck-gradle/plugin/src/test/kotlin/modulecheck/gradle/GraphReportTaskTest.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ internal class GraphReportTaskTest : BasePluginTest() {
109109
"app", "build", "reports", "modulecheck", "graphs", "main.dot"
110110
) shouldHaveText """
111111
strict digraph DependencyGraph {
112-
ratio=0.5;
113-
node [style="rounded,filled" shape=box];
112+
ratio = 0.5625;
113+
node [style = "rounded,filled" shape = box];
114+
115+
labelloc = "t"
116+
label = ":app -- main";
114117
115118
":app" [fillcolor = "#F89820"];
116119
":lib1" [fillcolor = "#F89820"];
@@ -121,9 +124,9 @@ internal class GraphReportTaskTest : BasePluginTest() {
121124
122125
":lib2" -> ":lib1" [style = bold; color = "#007744"];
123126
124-
{rank = same; ":lib1";}
125-
{rank = same; ":lib2";}
126-
{rank = same; ":app";}
127+
{ rank = same; ":lib1"; }
128+
{ rank = same; ":lib2"; }
129+
{ rank = same; ":app"; }
127130
}
128131
"""
129132
}

modulecheck-reporting/graphviz/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ dependencies {
3434
testImplementation(libs.bundles.hermit)
3535
testImplementation(libs.bundles.jUnit)
3636
testImplementation(libs.bundles.kotest)
37+
testImplementation(libs.kotlin.reflect)
38+
testImplementation(libs.rickBusarow.dispatch.test.core)
39+
40+
testImplementation(project(path = ":modulecheck-core"))
41+
testImplementation(project(path = ":modulecheck-project:api"))
42+
testImplementation(project(path = ":modulecheck-project:testing"))
43+
testImplementation(project(path = ":modulecheck-runtime:testing"))
3744
}

modulecheck-reporting/graphviz/src/main/kotlin/modulecheck/reporting/graphviz/GraphvizFactory.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ class GraphvizFactory @Inject constructor(
4949

5050
appendLine(
5151
"""
52-
|ratio=0.5;
53-
|node [style="rounded,filled" shape=box];
52+
|ratio = 0.5625;
53+
|node [style = "rounded,filled" shape = box];
54+
|
55+
|labelloc = "t"
56+
|label = "${root.dependentPath.value} -- ${root.sourceSetName.value}";
5457
|
5558
""".trimMargin()
5659
)
@@ -139,7 +142,7 @@ class GraphvizFactory @Inject constructor(
139142
.sortedBy { it.dependentPath }
140143
.joinToString("; ", postfix = ";") { it.dependentProject.pathString() }
141144

142-
appendLine("{rank = same; $paths}")
145+
appendLine("{ rank = same; $paths }")
143146
}
144147
}
145148

modulecheck-reporting/graphviz/src/main/kotlin/modulecheck/reporting/graphviz/GraphvizFileWriter.kt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,24 @@ class GraphvizFileWriter @Inject constructor(
3434
val rootOrNull = settings.reports.graphs.outputDir?.let { File(it) }
3535

3636
depths
37-
.filter {
38-
// Don't generate a graph if the SourceSet doesn't exist at all.
39-
// For example, if it's an Android project there will be an `androidTest` SourceSet,
40-
// but if there are no `androidTestImplementation` dependencies and no files, then skip it.
41-
it.depth != 0 || it.dependentProject
42-
.sourceSets[it.sourceSetName]
43-
?.hasExistingSourceFiles == true
44-
}
4537
// Generate the low-depth graphs first, because their data is memoized and used to create the
4638
// graphs for high-depth projects.
4739
.sorted()
4840
.forEach { depth ->
4941

5042
launchIO {
5143

52-
val root = rootOrNull ?: depth.dependentProject.projectDir
53-
54-
val graphFile = root.child(
55-
"build",
56-
"reports",
57-
"modulecheck",
58-
"graphs",
44+
val graphFile = rootOrNull?.child(
45+
depth.dependentPath.value.replace(":", File.separator),
5946
"${depth.sourceSetName.value}.dot"
6047
)
48+
?: depth.dependentProject.projectDir.child(
49+
"build",
50+
"reports",
51+
"modulecheck",
52+
"graphs",
53+
"${depth.sourceSetName.value}.dot"
54+
)
6155

6256
val depthReport = graphvizFactory.create(depth)
6357

0 commit comments

Comments
 (0)