Cache writer instance in kapt

This commit is contained in:
Yan Zhulanow
2015-05-26 19:47:32 +03:00
parent c2dd7d197e
commit 28a3865997
@@ -230,12 +230,15 @@ public class AnnotationCollectorExtension(
val outputFilename: String? = null val outputFilename: String? = null
) : AnnotationCollectorExtensionBase() { ) : AnnotationCollectorExtensionBase() {
private var writerInternal: Writer? = null
override fun getWriter(diagnostic: DiagnosticSink): Writer { override fun getWriter(diagnostic: DiagnosticSink): Writer {
try { return writerInternal ?: try {
return with (File(outputFilename)) { with (File(outputFilename)) {
val parent = getParentFile() val parent = getParentFile()
if (!parent.exists()) parent.mkdirs() if (!parent.exists()) parent.mkdirs()
bufferedWriter() writerInternal = bufferedWriter()
writerInternal!!
} }
} }
catch (e: IOException) { catch (e: IOException) {