IDEA-349489 cleanup

GitOrigin-RevId: 9def202a6695b98e937ad1803a0ef99bc47cff8e
This commit is contained in:
Vladimir Krivosheev
2024-03-23 16:58:24 +00:00
committed by intellij-monorepo-bot
parent 047b0de3d2
commit 25e047d2ba
2 changed files with 38 additions and 30 deletions
@@ -56,26 +56,26 @@ fun createCompilationContextBlocking(projectHome: Path,
defaultOutputRoot: Path,
options: BuildOptions = BuildOptions()): CompilationContextImpl {
return runBlocking(Dispatchers.Default) {
createCompilationContext(projectHome = projectHome,
defaultOutputRoot = defaultOutputRoot,
options = options)
createCompilationContext(projectHome = projectHome, defaultOutputRoot = defaultOutputRoot, options = options)
}
}
suspend fun createCompilationContext(projectHome: Path,
defaultOutputRoot: Path,
options: BuildOptions = BuildOptions()): CompilationContextImpl {
suspend fun createCompilationContext(
projectHome: Path,
defaultOutputRoot: Path,
options: BuildOptions = BuildOptions(),
): CompilationContextImpl {
val logDir = options.logDir ?: (options.outRootDir ?: defaultOutputRoot).resolve("log")
JaegerJsonSpanExporterManager.setOutput(logDir.toAbsolutePath().normalize().resolve("trace.json"))
return CompilationContextImpl.createCompilationContext(projectHome = projectHome,
setupTracer = false,
buildOutputRootEvaluator = { defaultOutputRoot },
options = options)
return CompilationContextImpl.createCompilationContext(
projectHome = projectHome,
setupTracer = false,
buildOutputRootEvaluator = { defaultOutputRoot },
options = options,
)
}
internal fun computeBuildPaths(options: BuildOptions,
project: JpsProject,
buildOutputRootEvaluator: (JpsProject) -> Path,
internal fun computeBuildPaths(options: BuildOptions, project: JpsProject, buildOutputRootEvaluator: (JpsProject) -> Path,
artifactPathSupplier: (() -> Path)?,
projectHome: Path,
): BuildPaths {
@@ -99,6 +99,7 @@ class CompilationContextImpl private constructor(
override val paths: BuildPaths,
override val options: BuildOptions,
) : CompilationContext {
@JvmField
val global: JpsGlobal = model.global
private val nameToModule: Map<String?, JpsModule>
@@ -188,10 +189,11 @@ class CompilationContextImpl private constructor(
isCompilationRequired = CompiledClasses.isCompilationRequired(options),
)
val buildPaths = computeBuildPaths(project = model.project,
options = options,
buildOutputRootEvaluator = buildOutputRootEvaluator,
projectHome = projectHome,
val buildPaths = computeBuildPaths(
project = model.project,
options = options,
buildOutputRootEvaluator = buildOutputRootEvaluator,
projectHome = projectHome,
artifactPathSupplier = null,
)
@@ -201,10 +203,7 @@ class CompilationContextImpl private constructor(
JaegerJsonSpanExporterManager.setOutput(buildPaths.logDir.resolve("trace.json"))
}
val context = CompilationContextImpl(model = model,
messages = messages,
paths = buildPaths,
options = options)
val context = CompilationContextImpl(model = model, messages = messages, paths = buildPaths, options = options)
/**
* [defineJavaSdk] may be skipped using [CompiledClasses.isCompilationRequired]
* after removing workaround from [JpsCompilationRunner.compileMissingArtifactsModules].
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.intellij.build.impl.logging
import com.intellij.platform.diagnostic.telemetry.helpers.use
@@ -16,14 +16,18 @@ import java.util.*
import java.util.concurrent.Callable
import java.util.function.Consumer
class BuildMessagesImpl private constructor(private val logger: BuildMessageLogger,
private val debugLogger: DebugLogger) : BuildMessages {
class BuildMessagesImpl private constructor(
private val logger: BuildMessageLogger,
private val debugLogger: DebugLogger,
) : BuildMessages {
companion object {
fun create(): BuildMessagesImpl {
val mainLoggerFactory = if (isUnderTeamCity) TeamCityBuildMessageLogger.FACTORY else ConsoleBuildMessageLogger.FACTORY
val debugLogger = DebugLogger()
return BuildMessagesImpl(logger = CompositeBuildMessageLogger(listOf(mainLoggerFactory(), debugLogger.createLogger())),
debugLogger = debugLogger)
return BuildMessagesImpl(
logger = CompositeBuildMessageLogger(listOf(mainLoggerFactory(), debugLogger.createLogger())),
debugLogger = debugLogger,
)
}
}
@@ -81,10 +85,15 @@ class BuildMessagesImpl private constructor(private val logger: BuildMessageLogg
override fun error(message: String, cause: Throwable) {
val writer = StringWriter()
PrintWriter(writer).use(cause::printStackTrace)
processMessage(LogMessage(kind = LogMessage.Kind.ERROR, text = """
$message
$writer
""".trimIndent()))
processMessage(
LogMessage(
kind = LogMessage.Kind.ERROR,
text = """
$message
$writer
""".trimIndent()
)
)
throw BuildScriptsLoggedError(message, cause)
}