Plugin development in Kotlin?


(štefan Jarina) #1

Hello,

does anyone have any experience with development of plugins using other JVM language than Java?
Prefferably Kotlin?

In our environment we generate a lot of logs in XML format and I couldn’t find any advanced XML plugin for complex XML files…
I would also like to avoid parsing XML using regex, that is just nasty and very error prone.
Did consider transforming xml to json before it reaches Graylog, but I have to use filebeat… maybe writing my own beat based on filebeat but with xml>json transformer might be also an option.

Anyway, writing a plugin is not a problem, but I realy realy would like to avoid pure Java at any cost and use Kotlin instead.
Is it possible? Did someone try to do it? Were there any issues?
Thanks a lot.


(Kay Roepke) #2

Hi!

I’ve never used Kotlin beyond some toy examples, but from what I know about it, I don’t think there should be any problem using it for plugin development.
I’d suggest starting with the standard Java maven archetype for plugins (found on maven central or in https://github.com/Graylog2/graylog2-server/tree/master/graylog-plugin-archetype (pick the branch corresponding to your intended target version instead of master).

Graylog uses maven, so I’d stick with that to be able to use both https://github.com/Graylog2/graylog-project-cli and https://github.com/Graylog2/graylog-project.
Then add the Kotlin maven compiler plugin and convert the classes the maven archetype generated for you to Kotlin. They are rather minimal, basically just supplying metadata for your plugin and providing some Guice modules for integration with the server.
Don’t forget the properties file in resources as that is being read by the server, too.

From there on it should be straightforward.

Hope that helps,
Kay


(system) #3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.