From 0d927b27b72ebdff36354424c85820104c8a4b82 Mon Sep 17 00:00:00 2001 From: Joel Wilcox Date: Thu, 31 Aug 2023 17:16:01 -0700 Subject: [PATCH] Update how we write the generated file, more logging --- .../codegen/ksp/SimpleSymbolProcessor.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt index ab5682a78..796e37ca9 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt @@ -8,6 +8,7 @@ import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSFile import com.squareup.anvil.compiler.api.AnvilApplicabilityChecker import com.squareup.anvil.compiler.internal.testing.parseSimpleFileContents +import java.io.OutputStream import java.io.OutputStreamWriter import java.nio.charset.StandardCharsets @@ -32,21 +33,21 @@ private class SimpleSymbolProcessor( sources = listOfNotNull(result.originatingFile).toTypedArray() ) val file = env.codeGenerator.createNewFile(dependencies, packageName, fileName) - - // Don't use writeTo(file) because that tries to handle directories under the hood - OutputStreamWriter(file, StandardCharsets.UTF_8) - .buffered() - .use { writer -> - writer.write(result.content) - writer.flush() - env.logger.info("Content written to file") - } + file.appendText(result.content) + env.logger.info("Content written to file") } .toList() + val files = resolver.getAllFiles().toList() + env.logger.info("All files : ${files.joinToString { it.fileName }}") + return emptyList() } } +fun OutputStream.appendText(str: String) { + this.write(str.toByteArray()) +} + internal data class SimpleMapperResult( val content: String, val originatingFile: KSFile?,