diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/NativePlatformUtil.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/NativePlatformUtil.kt index 8b8d2142e48..5ab030aa6a7 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/NativePlatformUtil.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/NativePlatformUtil.kt @@ -40,19 +40,19 @@ fun launchProcessWithFallback(processBuilder: ProcessBuilder, reportingTargets: NativePlatformLauncherWrapper().launch(processBuilder) } catch (e: UnsatisfiedLinkError) { - reportingTargets.report(DaemonReportCategory.DEBUG, "Could not start process with native process launcher, falling back to ProcessBuilder#start ($e)", reportingSource) + reportingTargets.report(DaemonReportCategory.EXCEPTION, "Could not start process with native process launcher, falling back to ProcessBuilder#start ($e)", reportingSource) null } catch (e: IOException) { - reportingTargets.report(DaemonReportCategory.DEBUG, "Could not start process with native process launcher, falling back to ProcessBuilder#start (${e.cause})", reportingSource) + reportingTargets.report(DaemonReportCategory.EXCEPTION, "Could not start process with native process launcher, falling back to ProcessBuilder#start (${e.cause})", reportingSource) null } catch (e: NoClassDefFoundError) { - reportingTargets.report(DaemonReportCategory.DEBUG, "net.rubygrapefruit.platform library is not in the classpath, falling back to ProcessBuilder#start ($e)", reportingSource) + reportingTargets.report(DaemonReportCategory.EXCEPTION, "net.rubygrapefruit.platform library is not in the classpath, falling back to ProcessBuilder#start ($e)", reportingSource) null } catch (e: ClassNotFoundException) { - reportingTargets.report(DaemonReportCategory.DEBUG, "net.rubygrapefruit.platform library is not in the classpath, falling back to ProcessBuilder#start ($e)", reportingSource) + reportingTargets.report(DaemonReportCategory.EXCEPTION, "net.rubygrapefruit.platform library is not in the classpath, falling back to ProcessBuilder#start ($e)", reportingSource) null } ?: processBuilder.start() diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt index 16aab4f9d5c..a2366965411 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.incremental import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.incremental.AbiSnapshotImpl.Companion.readAbiSnapshot import org.jetbrains.kotlin.incremental.AbiSnapshotImpl.Companion.writeAbiSnapshot +import org.jetbrains.kotlin.incremental.util.ExceptionLocation import org.jetbrains.kotlin.incremental.util.reportException import java.io.* @@ -51,7 +52,7 @@ data class BuildInfo(val startTS: Long, val dependencyToAbiSnapshot: Map { - messageCollector.reportException(result.cause) + messageCollector.reportException(result.cause, ExceptionLocation.INCREMENTAL_COMPILATION) reporter.warn { // The indentation after the first line is intentional (so that this message is distinct from next message) """ diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/util/messageCollectorUtil.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/util/messageCollectorUtil.kt index 7de9f1f5e93..8c9b36491d7 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/util/messageCollectorUtil.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/util/messageCollectorUtil.kt @@ -7,8 +7,13 @@ package org.jetbrains.kotlin.incremental.util import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector - -internal fun MessageCollector.reportException(e: Throwable) { - report(severity = CompilerMessageSeverity.EXCEPTION, message = "Incremental compilation failed:${e.message}\n${e.stackTraceToString()}") +public fun MessageCollector.reportException(e: Throwable, location: ExceptionLocation) { + report(severity = CompilerMessageSeverity.EXCEPTION, message = "$location failed:${e.message}\n${e.stackTraceToString()}") +} + +public enum class ExceptionLocation(val readablename: String) { + INCREMENTAL_COMPILATION("Incremental compilation"), + DAEMON("Daemon compilation"), + OUT_OF_PROCESS_COMPILATION("Out of process compilation") } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt index da0b99da273..98d8a677e81 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt @@ -22,6 +22,8 @@ import org.jetbrains.kotlin.gradle.utils.stackTraceAsString import org.jetbrains.kotlin.incremental.ChangedFiles import org.jetbrains.kotlin.incremental.ClasspathChanges import org.jetbrains.kotlin.incremental.IncrementalModuleInfo +import org.jetbrains.kotlin.incremental.util.ExceptionLocation +import org.jetbrains.kotlin.incremental.util.reportException import org.jetbrains.kotlin.util.removeSuffixIfPresent import org.slf4j.LoggerFactory import java.io.* @@ -153,6 +155,7 @@ internal class GradleKotlinCompilerWork @Inject constructor( try { return compileWithDaemon(messageCollector) to KotlinCompilerExecutionStrategy.DAEMON } catch (e: Throwable) { + messageCollector.reportException(e, ExceptionLocation.DAEMON) if (!compilerExecutionSettings.useDaemonFallbackStrategy) { throw RuntimeException( "Failed to compile with Kotlin daemon. Fallback strategy (compiling without Kotlin daemon) is turned off. " + diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt index 32a9328a652..8103b5d09b3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.daemon.client.DaemonReportingTargets import org.jetbrains.kotlin.daemon.client.launchProcessWithFallback +import org.jetbrains.kotlin.gradle.logging.GradleErrorMessageCollector import org.jetbrains.kotlin.gradle.logging.GradleKotlinLogger import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy import org.jetbrains.org.objectweb.asm.ClassReader @@ -107,13 +108,13 @@ internal fun runToolInSeparateProcess( compilerClassName, "@${compilerOptions.absolutePath}" ) - val messageCollector = createLoggingMessageCollector(logger) + val messageCollector = GradleErrorMessageCollector(createLoggingMessageCollector(logger)) val process = launchProcessWithFallback(builder, DaemonReportingTargets(messageCollector = messageCollector)) // important to read inputStream, otherwise the process may hang on some systems val readErrThread = thread { process.errorStream!!.bufferedReader().forEachLine { - logger.error(it) + messageCollector.report(CompilerMessageSeverity.EXCEPTION, it) } }