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:
Hung Nguyen
2022-06-16 15:56:41 +01:00
committed by teamcity
parent 623f832bfd
commit e01c2bc651
23 changed files with 358 additions and 118 deletions
@@ -9,8 +9,19 @@ import org.jetbrains.kotlin.cli.common.ExitCode
import java.io.File
interface ICReporter {
fun report(message: () -> String)
fun reportVerbose(message: () -> String)
enum class ReportSeverity(val level: Int) {
WARNING(3),
INFO(2),
DEBUG(1);
}
fun report(message: () -> String, severity: ReportSeverity)
// TODO: Move these 3 functions outside of this interface and make them extension functions so they can't be overridden
fun warn(message: () -> String) = report(message, severity = ReportSeverity.WARNING)
fun report(message: () -> String) = report(message, severity = ReportSeverity.INFO)
fun reportVerbose(message: () -> String) = report(message, severity = ReportSeverity.DEBUG)
fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode)
fun reportMarkDirtyClass(affectedFiles: Iterable<File>, classFqName: String)
@@ -19,8 +30,7 @@ interface ICReporter {
}
object DoNothingICReporter : ICReporter {
override fun report(message: () -> String) {}
override fun reportVerbose(message: () -> String) {}
override fun report(message: () -> String, severity: ICReporter.ReportSeverity) {}
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {}
override fun reportMarkDirtyClass(affectedFiles: Iterable<File>, classFqName: String) {}
override fun reportMarkDirtyMember(affectedFiles: Iterable<File>, scope: String, name: String) {}