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

Plugin-based architecture? #2

Closed
ankushg opened this issue Nov 9, 2021 · 3 comments
Closed

Plugin-based architecture? #2

ankushg opened this issue Nov 9, 2021 · 3 comments

Comments

@ankushg
Copy link

ankushg commented Nov 9, 2021

This project is super cool!

I'm curious if you'd explore a plugin-based architecture.

As an example, we have enums declared like:

enum class MyEnum(val value: String) {
  OPTION_A("option_a"),
  OPTION_B("option_b");
}

We'd love to write a custom rule that lets us export MyEnum as the underlying value (as a lightweight String), rather than a heavier class.

We also have other enum classes that use Ints.

@glureau
Copy link
Collaborator

glureau commented Nov 9, 2021

Thanks!

That was my first intention, but not sure how to setup a plugin-based architecture with KSP, but it could be interesting. If you know another project using this architecture with KMP I'm interested.

For the enum case, I don't think there is a lot of way to encode it: String, Int, or fully wrapped may be enough. I was thinking at an ExportMode in the annotation, something like that: #5

And it'll warn if there is a public method or field exposed as it cannot be exported in those modes for example. Is it matching your needs?

@glureau

This comment has been minimized.

@glureau
Copy link
Collaborator

glureau commented Feb 8, 2022

I tried many solutions but all were very limited, and eventually just a subset of what KSP offers.

I think that KSP already provides a "plugin-based architecture" in the sense that you could write your own KSP processor with your custom annotation, and use this annotation on the enums you want to generate differently for example. Given you respect the contract (2 methods import/export + expected package name) then it'll work with the other classes KustomExport is currently generating. So I'm closing this ticket for now.

Indeed, do not hesitate to re-open if you have a more specific need/approach on this topic.

@glureau glureau closed this as completed Feb 8, 2022
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