Skip to content

Commit d0be601

Browse files
committed
Make failing modules red on graph
1 parent 913e6fb commit d0be601

File tree

1 file changed

+72
-60
lines changed

1 file changed

+72
-60
lines changed

buildSrc/src/main/kotlin/io/micronaut/build/ProjectGraphBuilder.kt

Lines changed: 72 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,20 @@ abstract class ProjectGraphBuilder : DefaultTask() {
202202
}
203203
}
204204
if (remainingDependencies.isNotEmpty()) {
205-
warnings.add("""
205+
warnings.add(
206+
"""
206207
[WARNING] Could not find a cluster for $remainingDependencies.
207208
This can be caused by a project missing in the checkouts list or a failing build.
208-
""".trimIndent())
209+
""".trimIndent()
210+
)
209211
if (allClusters.isEmpty()) {
210212
// Don't throw! Just warn and proceed.
211-
warnings.add("""
213+
warnings.add(
214+
"""
212215
[WARNING] No previous clusters exist when trying to link dependencies for ${current.joinToString()}.
213216
This likely means the build graph is missing some modules, or initial project(s) have unresolved dependencies.
214-
""".trimIndent())
217+
""".trimIndent()
218+
)
215219
// Do not attempt to add a fallback edge, just continue.
216220
} else {
217221
val previous = allClusters.values.last()
@@ -286,6 +290,7 @@ abstract class ProjectGraphBuilder : DefaultTask() {
286290
private fun ModuleMetadata?.color() = when (this?.status) {
287291
"SNAPSHOT" -> "white"
288292
"RELEASE" -> "aquamarine"
293+
"ERROR" -> "crimson"
289294
else -> "aquamarine2"
290295
}
291296

@@ -297,65 +302,66 @@ abstract class ProjectGraphBuilder : DefaultTask() {
297302
it.extension != "properties"
298303
}.thenBy { it.name })
299304
.forEach { dependencyFile ->
300-
if (dependencyFile.name.endsWith(".properties")) {
301-
println("[ProjectGraphBuilder] Processing properties file: ${dependencyFile.absolutePath}")
302-
val dependencies = mutableSetOf<String>()
303-
val props = Properties()
304-
dependencyFile.inputStream().use { props.load(it) }
305-
val groupId = props.get("groupId").toString()
306-
val name = groupId.toProjectName()
307-
val allDependencies = props.get("dependencies").toString().trim()
308-
if (allDependencies != "") {
309-
allDependencies.split(",").forEach { dependency ->
310-
dependencies.add(dependency.toProjectName())
305+
println(dependencyFile)
306+
if (dependencyFile.name.endsWith(".properties")) {
307+
println("[ProjectGraphBuilder] Processing properties file: ${dependencyFile.absolutePath}")
308+
val dependencies = mutableSetOf<String>()
309+
val props = Properties()
310+
dependencyFile.inputStream().use { props.load(it) }
311+
val groupId = props.get("groupId").toString()
312+
val name = groupId.toProjectName()
313+
val allDependencies = props.get("dependencies").toString().trim()
314+
if (allDependencies != "") {
315+
allDependencies.split(",").forEach { dependency ->
316+
dependencies.add(dependency.toProjectName())
317+
}
318+
if (name == "gradle") {
319+
// Add an implicit dependency to platform, which is not captured by the tool
320+
// because it's added at runtime only by the plugin
321+
dependencies.add("platform")
322+
}
311323
}
312-
if (name == "gradle") {
313-
// Add an implicit dependency to platform, which is not captured by the tool
314-
// because it's added at runtime only by the plugin
315-
dependencies.add("platform")
324+
if (projectToMetadata.containsKey(name)) {
325+
throw IllegalStateException("Duplicate project name: $name, found in $dependencyFile and ${projectToMetadata.get(name)?.dependencyFile}")
316326
}
327+
println("[ProjectGraphBuilder] -> Loaded project '$name', $props")
328+
projectToMetadata[name] = ModuleMetadata(
329+
name,
330+
props.get("version").toString(),
331+
groupId,
332+
props.get("status").toString(),
333+
props.get("githubSlug").toString(),
334+
props.get("micronautVersion").toString(),
335+
props.get("gradleVersion").toString(),
336+
props.get("settingsPluginVersion").toString(),
337+
latestBuildPluginsVersion.get(),
338+
props.get("build-status")?.toString(),
339+
dependencies.toList(),
340+
dependencyFile
341+
)
342+
} else if (dependencyFile.name == "ERROR") {
343+
val name = projectDir.name.substring("reportForMicronaut".length).lowercase()
344+
println("[ProjectGraphBuilder] ERROR: Found build ERROR for project '$name' (file: ${dependencyFile.absolutePath})")
345+
val msg = dependencyFile.readText().trim()
346+
if (msg.isNotEmpty()) {
347+
println("[ProjectGraphBuilder] -> ERROR details: $msg")
348+
}
349+
projectToMetadata[name] = ModuleMetadata(
350+
name,
351+
"ERROR",
352+
"ERROR",
353+
"ERROR",
354+
"ERROR",
355+
"ERROR",
356+
"ERROR",
357+
"ERROR",
358+
latestBuildPluginsVersion.get(),
359+
"ERROR",
360+
emptyList(),
361+
dependencyFile
362+
)
317363
}
318-
if (projectToMetadata.containsKey(name)) {
319-
throw IllegalStateException("Duplicate project name: $name, found in $dependencyFile and ${projectToMetadata.get(name)?.dependencyFile}")
320-
}
321-
println("[ProjectGraphBuilder] -> Loaded project '$name', $props")
322-
projectToMetadata[name] = ModuleMetadata(
323-
name,
324-
props.get("version").toString(),
325-
groupId,
326-
props.get("status").toString(),
327-
props.get("githubSlug").toString(),
328-
props.get("micronautVersion").toString(),
329-
props.get("gradleVersion").toString(),
330-
props.get("settingsPluginVersion").toString(),
331-
latestBuildPluginsVersion.get(),
332-
props.get("build-status")?.toString(),
333-
dependencies.toList(),
334-
dependencyFile
335-
)
336-
} else if (dependencyFile.name == "ERROR") {
337-
val name = projectDir.name.substring("reportForMicronaut".length).lowercase()
338-
println("[ProjectGraphBuilder] ERROR: Found build ERROR for project '$name' (file: ${dependencyFile.absolutePath})")
339-
val msg = dependencyFile.readText().trim()
340-
if (msg.isNotEmpty()) {
341-
println("[ProjectGraphBuilder] -> ERROR details: $msg")
342-
}
343-
projectToMetadata[name] = ModuleMetadata(
344-
name,
345-
"ERROR",
346-
"ERROR",
347-
"ERROR",
348-
"ERROR",
349-
"ERROR",
350-
"ERROR",
351-
"ERROR",
352-
latestBuildPluginsVersion.get(),
353-
"ERROR",
354-
emptyList(),
355-
dependencyFile
356-
)
357364
}
358-
}
359365
}
360366
return projectToMetadata
361367
}
@@ -517,7 +523,13 @@ abstract class ProjectGraphBuilder : DefaultTask() {
517523
fun asHtml() = """<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="1" STYLE="rounded">
518524
|<TR><TD><B>$name $version</B></TD></TR>
519525
|<TR><TD>${statusEmoji} Status $status</TD></TR>
520-
|${if (name!="core") {"""<TR><TD>${micronautEmoji} Micronaut $micronautVersion</TD></TR>"""} else {""} }
526+
|${
527+
if (name != "core") {
528+
"""<TR><TD>${micronautEmoji} Micronaut $micronautVersion</TD></TR>"""
529+
} else {
530+
""
531+
}
532+
}
521533
|<TR><TD>${gradleEmoji} Gradle $gradleVersion</TD></TR>
522534
|<TR><TD>${settingsEmoji} Settings $settingsPluginVersion</TD></TR>
523535
|${if (buildStatus != null) """<TR><TD>${buildStatusHtml}</TD></TR>""" else ""}

0 commit comments

Comments
 (0)