Skip to content

Commit 9101ce4

Browse files
authored
Fix build.gradle error causing projectsEvaluated to never run (#691)
1 parent b159cd5 commit 9101ce4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugins/src/main/java/com/jraska/gradle/buildtime/BuildTimeListener.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class BuildTimeListener(
1414
private val buildReporter: BuildReporter
1515
) : BuildListener {
1616
private val taskExecutionStatisticsEventAdapter = TaskExecutionStatisticsEventAdapter()
17-
private var configuredTime: Long = 0
17+
private var configuredTime: Long? = null
1818

1919
override fun settingsEvaluated(gradle: Settings) = Unit
2020
override fun projectsLoaded(gradle: Gradle) = Unit
@@ -26,7 +26,13 @@ internal class BuildTimeListener(
2626
}
2727

2828
override fun buildFinished(result: BuildResult) {
29-
val buildData = buildDataFactory.buildData(result, taskExecutionStatisticsEventAdapter.statistics, configuredTime)
29+
if (configuredTime == null) {
30+
val gradle = result.gradle as DefaultGradle
31+
val services = gradle.services
32+
33+
configuredTime = services[Clock::class.java].currentTime
34+
}
35+
val buildData = buildDataFactory.buildData(result, taskExecutionStatisticsEventAdapter.statistics, configuredTime!!)
3036

3137
println("Build data collected in ${buildData.buildDataCollectionOverhead} ms")
3238

0 commit comments

Comments
 (0)