What are my options for a plugin/extension archite...
# getting-started
m
What are my options for a plugin/extension architecture in a Kotlin app? I'd like it to be possible for someone to extend my application (without actually having to modify my application). An example of what I want to achieve is what VLC does.
r
There's not really enough information here to answer your question, especially which platform you're targeting. Assuming you're targeting desktop JVM, the standard is (was?) OSGi, but it's pretty heavy duty. If you want something simpler, you could look into something like PF4J: https://github.com/pf4j/pf4j or roll your own using the
ServiceProvider
interface.
m
A desktop JVM app, yes. PF4J does look interesting. I did investigate OSGi a bit, but it seemed to be bringing in a lot of complexity. But Java-based solutions probably mean I wouldn't be able to expose
@Composable
methods to the plugins.
r
You'd have to try it out, but I would be surprised if there was an issue. PF4J (as far as I understand it) is essentially just an annotation scanner for interfaces and classes. I don't see why it would care what functions those classes have. It probably does mean all your `@Composable`s would need to be in interfaces and classes though. I don't know how you'd do top level functions (as those are static and thus can't be part of an implementation).
👍 1
103 Views