Warn in Gradle log when incremental compilation fails
When incremental compilation fails, we currently log it at the `debug` level (and fall back to non-incremental compilation). This commit will change it to `warning` so that we can get more user reports, which will allow us to fix the root cause. Also make sure the warning includes a stack trace. Additionally, let ReportSeverity.fromCode() return a non-null value or throw an exception otherwise as that case is not expected. ^KT-52839 In Progress
This commit is contained in:
+7
-4
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.incremental.parsing.classesFqNames
|
||||
import org.jetbrains.kotlin.incremental.util.BufferingMessageCollector
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.util.suffixIfNot
|
||||
import java.io.File
|
||||
|
||||
abstract class IncrementalCompilerRunner<
|
||||
@@ -179,8 +180,9 @@ abstract class IncrementalCompilerRunner<
|
||||
}
|
||||
return exitCode
|
||||
} catch (e: Throwable) {
|
||||
reporter.report {
|
||||
"Incremental compilation failed: ${e.stackTraceToString()}.\nFalling back to non-incremental compilation."
|
||||
reporter.warn {
|
||||
"Incremental compilation failed: ${e.stackTraceToString().suffixIfNot("\n")}" +
|
||||
"Falling back to non-incremental compilation"
|
||||
}
|
||||
rebuildReason = BuildAttribute.INCREMENTAL_COMPILATION_FAILED
|
||||
}
|
||||
@@ -188,8 +190,9 @@ abstract class IncrementalCompilerRunner<
|
||||
is CompilationMode.Rebuild -> rebuildReason = compilationMode.reason
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
reporter.report {
|
||||
"Incremental compilation analysis failed: ${e.stackTraceToString()}.\nFalling back to non-incremental compilation."
|
||||
reporter.warn {
|
||||
"Incremental compilation analysis failed: ${e.stackTraceToString().suffixIfNot("\n")}" +
|
||||
"Falling back to non-incremental compilation"
|
||||
}
|
||||
} finally {
|
||||
if (!caches.close(flush = true)) {
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
|
||||
class ClasspathSnapshotBuildReporter(private val buildReporter: BuildReporter) :
|
||||
ICReporter by buildReporter, BuildMetricsReporter by buildReporter {
|
||||
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
buildReporter.reportVerbose { "[ClasspathSnapshot] ${message()}" }
|
||||
override fun report(message: () -> String, severity: ICReporter.ReportSeverity) {
|
||||
buildReporter.report({ "[ClasspathSnapshot] ${message()}" }, severity)
|
||||
}
|
||||
|
||||
fun reportVerboseWithLimit(maxLength: Int = 1000, message: () -> String) {
|
||||
|
||||
+2
-4
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.incremental.utils
|
||||
|
||||
import org.jetbrains.kotlin.build.report.ICReporter.ReportSeverity
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.build.report.ICReporterBase
|
||||
import java.io.File
|
||||
@@ -29,10 +30,7 @@ class TestICReporter : ICReporterBase() {
|
||||
var exitCode: ExitCode = ExitCode.OK
|
||||
private set
|
||||
|
||||
override fun report(message: () -> String) {
|
||||
}
|
||||
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
override fun report(message: () -> String, severity: ReportSeverity) {
|
||||
}
|
||||
|
||||
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
|
||||
Reference in New Issue
Block a user