kotshi icon indicating copy to clipboard operation
kotshi copied to clipboard

Disabling code gen in debug builds

Open helloseyedjafari opened this issue 7 years ago • 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)

helloseyedjafari avatar Oct 01 '18 05:10 helloseyedjafari

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

JakeWharton avatar Oct 01 '18 13:10 JakeWharton

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.

helloseyedjafari avatar Oct 02 '18 04:10 helloseyedjafari

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.

ansman avatar Oct 02 '18 19:10 ansman