mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -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 val projectInfos = hashMapOf<String, ProjectInfo>()
|
||||||
private var hasFailures = false
|
private var hasFailures = false
|
||||||
private val args: Args get() = Kobalt.INJECTOR.getInstance(Args::class.java)
|
private val args: Args get() = Kobalt.INJECTOR.getInstance(Args::class.java)
|
||||||
|
private var buildStartTime: Long? = null
|
||||||
|
|
||||||
// IBuildListener
|
// IBuildListener
|
||||||
override fun taskStart(project: Project, context: KobaltContext, taskName: String) {
|
override fun taskStart(project: Project, context: KobaltContext, taskName: String) {
|
||||||
|
@ -41,6 +42,11 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
||||||
|
|
||||||
private val projectStatuses = arrayListOf<Pair<Project, ProjectBuildStatus>>()
|
private val projectStatuses = arrayListOf<Pair<Project, ProjectBuildStatus>>()
|
||||||
|
|
||||||
|
// IBuildListener
|
||||||
|
override fun projectStart(project: Project, context: KobaltContext) {
|
||||||
|
if (buildStartTime == null) buildStartTime = System.currentTimeMillis()
|
||||||
|
}
|
||||||
|
|
||||||
// IBuildListener
|
// IBuildListener
|
||||||
override fun projectEnd(project: Project, context: KobaltContext, status: ProjectBuildStatus) {
|
override fun projectEnd(project: Project, context: KobaltContext, status: ProjectBuildStatus) {
|
||||||
projectStatuses.add(Pair(project, status))
|
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 formatMillisRight(millis: Long, length: Int) = formatMillis(millis, "%1\$$length.2f")
|
||||||
fun formatMillisLeft(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
|
val profiling = args.profiling
|
||||||
if (profiling) {
|
if (profiling) {
|
||||||
log(1, "\n" + AsciiArt.horizontalSingleLine + " Timings (in seconds)")
|
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.verticalBar + " " + cl + " " + AsciiArt.verticalBar)
|
||||||
}
|
}
|
||||||
log(1, " " + AsciiArt.lowerBox(line.length))
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,18 +114,14 @@ private class Main @Inject constructor(
|
||||||
var result = 0
|
var result = 0
|
||||||
val latestVersionFuture = github.latestKobaltVersion
|
val latestVersionFuture = github.latestKobaltVersion
|
||||||
|
|
||||||
val timing = benchmarkSeconds {
|
try {
|
||||||
try {
|
result = runWithArgs(jc, args, argv, pluginClassLoader)
|
||||||
result = runWithArgs(jc, args, argv, pluginClassLoader)
|
} catch(ex: Throwable) {
|
||||||
} catch(ex: Throwable) {
|
error("", ex.cause ?: ex)
|
||||||
error("", ex.cause ?: ex)
|
result = 1
|
||||||
result = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.update) {
|
if (!args.update) {
|
||||||
log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL (${timing.first} seconds)")
|
|
||||||
|
|
||||||
updateKobalt.checkForNewVersion(latestVersionFuture)
|
updateKobalt.checkForNewVersion(latestVersionFuture)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue