Print stacktrace to Gradle logger instead of writing directly to stderr
This commit is contained in:
+6
-8
@@ -17,13 +17,11 @@ import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||
import org.jetbrains.kotlin.gradle.tasks.GradleMessageCollector
|
||||
import org.jetbrains.kotlin.gradle.tasks.clearLocalStateDirectories
|
||||
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
|
||||
import org.jetbrains.kotlin.gradle.utils.stackTraceAsString
|
||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||
import org.jetbrains.kotlin.incremental.DELETE_MODULE_FILE_PROPERTY
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.PrintStream
|
||||
import java.io.Serializable
|
||||
import java.io.*
|
||||
import java.net.URLClassLoader
|
||||
import java.rmi.RemoteException
|
||||
import javax.inject.Inject
|
||||
@@ -155,8 +153,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
log.isDebugEnabled
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
log.warn("Caught an exception trying to connect to Kotlin Daemon")
|
||||
e.printStackTrace()
|
||||
log.error("Caught an exception trying to connect to Kotlin Daemon:")
|
||||
log.error(e.stackTraceAsString())
|
||||
null
|
||||
}
|
||||
if (connection == null) {
|
||||
@@ -183,8 +181,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
}
|
||||
exitCodeFromProcessExitCode(log, res.get())
|
||||
} catch (e: Throwable) {
|
||||
log.warn("Compilation with Kotlin compile daemon was not successful")
|
||||
e.printStackTrace()
|
||||
log.error("Compilation with Kotlin compile daemon was not successful")
|
||||
log.error(e.stackTraceAsString())
|
||||
null
|
||||
}
|
||||
// todo: can we clear cache on the end of session?
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
internal fun Throwable.stackTraceAsString(): String {
|
||||
val writer = StringWriter()
|
||||
printStackTrace(PrintWriter(writer))
|
||||
return writer.toString()
|
||||
}
|
||||
Reference in New Issue
Block a user