Cache writer instance in kapt
This commit is contained in:
+6
-3
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user