Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best practices in multi-modular projects #309

Open
charlee-dev opened this issue May 17, 2024 · 1 comment
Open

Best practices in multi-modular projects #309

charlee-dev opened this issue May 17, 2024 · 1 comment

Comments

@charlee-dev
Copy link

Hi. I just have a question about a Kotlin best practices in multi-modular projects.

In the current setup I have multiple sub-modules with its own models annotated with @JsonSerializable and Factories. So each of them have the factory generated in the build directory, Then in the top module which is a lambda function module in my case I create moshi instance and I add all factories from submodules to it.

Is this a right approach?
Will it be possible for Kotshi to automatically gather those factories and create one wrapper factory?

@ansman
Copy link
Owner

ansman commented May 17, 2024

Unfortunately Kotshi doesn't have support for generating aggregate factories across modules. This mostly stems from a limitation in KSP/KAPT as it can only find annotated classes in a single module. There are ways around this that Hilt uses for example but they aren't ideal here.

I've been considering adding support for Moshi's codegen which would let you skip adding a factory all together but it does require reflection and some proguard rules to be generated.

For now your options are either to create one factory per module like you do now or to switch to Moshi's official codegen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants