ansman/kotshi

Disabling code gen in debug builds

seyedjafariy opened this issue · 3 comments

Is there a way to disable the adapter code generation?
something similar to @JsonClass(generateAdapter = false) in Moshi code gen.

its especially useful in debug builds since we need fast iteration. (Moshi also provides Kotlin Reflect Adapter which we can make use of in debug build tool)

Use releaseAnnotationProcessor or check if (properties.containsKey('android.injected.invoked.from.ide')) before adding the regular annotationProcessor dependency.

releaseAnnotationProcessor is a good way to block the code gen.
but then I have to make my Moshi builder flavored specific(release and debug), in order to overcome the generation of KotshiApplicationJsonAdapterFactory() class in release builds only.

The answer is no, there is no way besides not applying the processor. As you mention you would have to have a separate factory in another source set. I will consider adding this feature when I switch to generating Kotlin code.