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
) : AnnotationCollectorExtensionBase() {
private var writerInternal: Writer? = null
override fun getWriter(diagnostic: DiagnosticSink): Writer {
try {
return with (File(outputFilename)) {
return writerInternal ?: try {
with (File(outputFilename)) {
val parent = getParentFile()
if (!parent.exists()) parent.mkdirs()
bufferedWriter()
writerInternal = bufferedWriter()
writerInternal!!
}
}
catch (e: IOException) {