From f8c44be865379d3b1950be57b5c884cfc66b8911 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 14 Apr 2020 20:01:39 +0300 Subject: [PATCH] [Gradle, JS] Config errors in webpack #KT-38286 fixed --- .../targets/js/TeamCityMessageCommonClient.kt | 13 ++++++++++++- .../js/TeamCityMessageStackTraceProcessor.kt | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageCommonClient.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageCommonClient.kt index 211801f30d4c6..86d53629de31b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageCommonClient.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageCommonClient.kt @@ -16,6 +16,9 @@ class TeamCityMessageCommonClient( private val log: Logger, private val progressLogger: ProgressLogger ) : ServiceMessageParserCallback { + + private val stackTraceProcessor = TeamCityMessageStackTraceProcessor() + override fun parseException(e: ParseException, text: String) { log.error("Failed to parse test process messages: \"$text\"", e) } @@ -30,7 +33,15 @@ class TeamCityMessageCommonClient( val value = text.trimEnd() progressLogger.progress(value) - type?.let { log.processLogMessage(value, it) } + var actualType = type + stackTraceProcessor.process(text) { line -> + actualType = ERROR + if (line != null) { + printMessage(line, actualType) + } + } + + actualType?.let { log.processLogMessage(value, it) } } override fun regularText(text: String) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageStackTraceProcessor.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageStackTraceProcessor.kt index 675abba564158..c6092a562ca38 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageStackTraceProcessor.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/TeamCityMessageStackTraceProcessor.kt @@ -10,6 +10,8 @@ internal class TeamCityMessageStackTraceProcessor { fun process(text: String, firstLineAction: (String?) -> Unit) { firstLine = if (text.trim().startsWith("at ")) { + // firstLineAction can have side effects + // that's why important to call it even with null line firstLineAction(firstLine) null } else {