mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[build scripts] making BuildMessages#block friendlier to Java code
GitOrigin-RevId: b9b465fe02986770dbb20a5e76fbf4e1ae856e6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
efa452a5d8
commit
248f893cd0
@@ -1,6 +1,8 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import com.intellij.openapi.util.ThrowableComputable
|
||||
|
||||
interface BuildMessages: System.Logger {
|
||||
fun info(message: String)
|
||||
|
||||
@@ -26,7 +28,7 @@ interface BuildMessages: System.Logger {
|
||||
|
||||
fun setParameter(parameterName: String, value: String)
|
||||
|
||||
fun <V> block(blockName: String, task: () -> V): V
|
||||
fun <V> block(blockName: String, task: ThrowableComputable<V, Exception>): V
|
||||
|
||||
fun artifactBuilt(relativeArtifactPath: String)
|
||||
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@
|
||||
package org.jetbrains.intellij.build.impl.logging
|
||||
|
||||
import com.intellij.diagnostic.telemetry.useWithScope
|
||||
import com.intellij.openapi.util.ThrowableComputable
|
||||
import com.intellij.util.containers.Stack
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.TraceManager.spanBuilder
|
||||
@@ -120,12 +121,12 @@ class BuildMessagesImpl private constructor(private val logger: BuildMessageLogg
|
||||
processMessage(LogMessage(LogMessage.Kind.SET_PARAMETER, "$parameterName=$value"))
|
||||
}
|
||||
|
||||
override fun <V> block(blockName: String, task: () -> V): V {
|
||||
override fun <V> block(blockName: String, task: ThrowableComputable<V, Exception>): V {
|
||||
spanBuilder(blockName.lowercase(Locale.getDefault())).useWithScope {
|
||||
try {
|
||||
blockNames.push(blockName)
|
||||
processMessage(LogMessage(LogMessage.Kind.BLOCK_STARTED, blockName))
|
||||
return task()
|
||||
return task.compute()
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
// print all pending spans
|
||||
@@ -219,4 +220,4 @@ private class PrintWriterBuildMessageLogger(
|
||||
override fun dispose() {
|
||||
disposer.accept(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user