mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Move the BUILD SUCCESSFUL message to the build listener.
This commit is contained in:
parent
635cc9cd3c
commit
1969252d16
2 changed files with 27 additions and 11 deletions
|
@ -18,6 +18,7 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
|||
private val projectInfos = hashMapOf<String, ProjectInfo>()
|
||||
private var hasFailures = false
|
||||
private val args: Args get() = Kobalt.INJECTOR.getInstance(Args::class.java)
|
||||
private var buildStartTime: Long? = null
|
||||
|
||||
// IBuildListener
|
||||
override fun taskStart(project: Project, context: KobaltContext, taskName: String) {
|
||||
|
@ -41,6 +42,11 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
|||
|
||||
private val projectStatuses = arrayListOf<Pair<Project, ProjectBuildStatus>>()
|
||||
|
||||
// IBuildListener
|
||||
override fun projectStart(project: Project, context: KobaltContext) {
|
||||
if (buildStartTime == null) buildStartTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
// IBuildListener
|
||||
override fun projectEnd(project: Project, context: KobaltContext, status: ProjectBuildStatus) {
|
||||
projectStatuses.add(Pair(project, status))
|
||||
|
@ -52,6 +58,9 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
|||
fun formatMillisRight(millis: Long, length: Int) = formatMillis(millis, "%1\$$length.2f")
|
||||
fun formatMillisLeft(millis: Long, length: Int) = formatMillis(millis, "%1\$-$length.2f")
|
||||
|
||||
fun millisToSeconds(millis: Long) = (millis.toDouble() / 1000).toInt()
|
||||
val buildTime = millisToSeconds(System.currentTimeMillis() - buildStartTime!!)
|
||||
|
||||
val profiling = args.profiling
|
||||
if (profiling) {
|
||||
log(1, "\n" + AsciiArt.horizontalSingleLine + " Timings (in seconds)")
|
||||
|
@ -79,10 +88,21 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
|||
log(1, " " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar)
|
||||
}
|
||||
log(1, " " + AsciiArt.lowerBox(line.length))
|
||||
if (args.parallel) log(1, "Sequential build time would be " +
|
||||
(projectInfos.values.sumByDouble { it.durationMillis.toDouble() }) / 1000 + " seconds")
|
||||
// }
|
||||
|
||||
// BUILD SUCCESSFUL / FAILED message
|
||||
val message = StringBuilder(if (args.parallel) "PARALLEL " else "")
|
||||
.append(if (hasFailures) "BUILD FAILED" else "BUILD SUCCESSFUL ($buildTime seconds")
|
||||
|
||||
if (args.parallel) {
|
||||
val sequentialBuildTime = ((projectInfos.values.sumByDouble { it.durationMillis.toDouble() }) / 1000)
|
||||
.toInt()
|
||||
message.append(", sequential build would have been $sequentialBuildTime seconds)")
|
||||
} else {
|
||||
message.append(")")
|
||||
}
|
||||
log(1, message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue