Jiaxiang
02/11/2021, 11:06 PMCompilationErrorException
use case?Zac Sweers
02/11/2021, 11:09 PM./gradlew :moshi-ksp:moshi-ksp:test
, which relies on this behavior in JsonClassSymbolProcessorTest
. The code for the logger that throws this is in JsonClassSymbolProcessor
itself, near the bottom. It just wraps KSPLogger
and throws it in finish()
if any errors were recordedAlex Vanyo
02/12/2021, 2:59 AM1.4.30-1.0.0-alpha02
here: https://github.com/livefront/sealed-enum/pull/32/commits/a02cd4050c17b1e8d146b465db0bc4c9716b3133
It looks like the behavior is now:
SymbolProcessor.finish()
is now only called if the compilation was successful (logger had previously encountered no errors)
SymbolProcessor.onError()
is called instead if the compilation wasn't successful, and throwing CompilationErrorException()
here still fails compilation.
However, since the logging is now deferred until after finish()
and onError()
, when I threw the error in CompilationErrorException()
my errors are never actually logged.
Right now I cast the logger
to MessageCollectorBasedKSPLogger
as a workaround to print the errors before throwing to still get a KotlinCompilation.ExitCode.COMPILATION_ERROR
, but that probably shouldn't be necessary.Zac Sweers
02/14/2021, 6:11 AMTing-Yuan Huang
02/24/2021, 1:59 AMCompilationErrorException
as a workaround.