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
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ class GradleInsightsPlugin @Inject constructor(private val registry: BuildEvents
systemLoadModule.getSystemLoadReportProvider()?.let {
buildServiceSpec.parameters.systemLoadReportService.set(it)
}

val startParameter = project.gradle.startParameter
val parts = mutableListOf<String>()
startParameter.projectDir?.let { projectDir ->
val rootPath = project.rootProject.rootDir.toPath()
val projectPath = projectDir.toPath()
val p = try {
val rel = rootPath.relativize(projectPath).toString()
rel.ifEmpty { "." }
} catch (e: IllegalArgumentException) {
// Fallback if paths are on different roots (e.g., different drives)
projectPath.toString()
}
parts.add("-p $p")
}
if (startParameter.taskNames.isNotEmpty()) {
parts.add(startParameter.taskNames.joinToString(" "))
}
buildServiceSpec.parameters.startParameters.set(parts.joinToString(" "))
}
registry.onTaskCompletion(compositeReportBuildService)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package com.smplio.gradle.build.insights.modules.timing.models

import java.io.Serializable

data class BuildInfo(
val status: ExecutionStatus,
): Serializable {
sealed class ExecutionStatus {
class Success : ExecutionStatus()
class Failed : ExecutionStatus()
data class BuildInfo(
val status: ExecutionStatus,
val startParameters: String = "",
): Serializable {
sealed class ExecutionStatus {
class Success : ExecutionStatus()
class Failed : ExecutionStatus()

override fun toString(): String {
return when (this) {
is Success -> "SUCCESS"
is Failed -> "FAILED"
}
}
}
}
override fun toString(): String {
return when (this) {
is Success -> "SUCCESS"
is Failed -> "FAILED"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ abstract class CompositeReportBuildService : BuildService<CompositeReportBuildSe
val systemLoadReportService: Property<SystemLoadService>
val configurationTimeReportService: Property<ConfigurationTimeMeasurementService>
val executionTimeReportService: Property<TaskExecutionTimeMeasurementService>
val startParameters: Property<String>
}

override fun close() {
Expand Down Expand Up @@ -67,7 +68,8 @@ abstract class CompositeReportBuildService : BuildService<CompositeReportBuildSe
measuredInstance = BuildInfo(
status = BuildInfo.ExecutionStatus.Success().takeIf {
!taskExecutionTimeline.isNullOrEmpty() && taskExecutionTimeline.none { it.measuredInstance.status is TaskInfo.ExecutionStatus.Failed }
} ?: BuildInfo.ExecutionStatus.Failed()
} ?: BuildInfo.ExecutionStatus.Failed(),
startParameters = parameters.startParameters.orNull ?: ""
),
startTime = min(configurationTimeline?.minOfOrNull { it.startTime } ?: 0L, taskExecutionTimeline?.minOfOrNull { it.startTime } ?: 0L),
endTime = max(configurationTimeline?.maxOfOrNull { it.endTime } ?: 0L, taskExecutionTimeline?.maxOfOrNull { it.endTime } ?: 0L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ class HTMLReporter(
private var configurationTimeJson: String? = null
private var executionTimeJson: String? = null
private var systemLoadJson: String? = null
private var startParametersText: String? = null

override fun reportExecutionStats(stats: ExecutionStats) {
stats.configurationTimeline?.let { reportConfigurationTime(it) }
stats.taskExecutionTimeline?.let { reportTaskExecutionTime(it) }
startParametersText = stats.buildInfo.measuredInstance.startParameters
}

override fun reportTaskExecutionTime(taskExecutionTimeReport: TaskExecutionTimeReport) {
Expand Down Expand Up @@ -86,6 +88,7 @@ class HTMLReporter(
val buildChartsJsText = javaClass.getResourceAsStream("/build_charts.js")?.reader()?.use { it.readText() }

val html = javaClass.getResourceAsStream("/index.html")?.reader()?.readText()?.format(
startParametersText ?: "",
configurationTimeJson ?: "",
executionTimeJson ?: "",
systemLoadJson ?: "",
Expand All @@ -109,6 +112,7 @@ class HTMLReporter(
configurationTimeJson = null
executionTimeJson = null
systemLoadJson = null
startParametersText = null

println("Build insights report is available in file://${reportHtmlFile.absolutePath}")
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/build_charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ new Chart(cpuChart, {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y;
label += Math.round(context.parsed.y);
}
label += '%';
return label;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header"><h2>%s</h2></div>
<div>
<!-- Task container above the timeline -->
<div id="task-timeline" class="task-timeline overflow-container"></div>
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
body {
font-family: Arial, sans-serif;
margin: 0;
}

.overflow-container {
Expand Down Expand Up @@ -152,4 +153,18 @@ body {
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}

/* Header bar */
.header {
width: 100%;
background: #ffffff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
padding: 12px 16px;
}

.header h2 {
margin: 0 0 6px 0;
font-size: 16px;
color: #333;
}
Loading