CommandAPI icon indicating copy to clipboard operation
CommandAPI copied to clipboard

Kotlin Annotation Processor

Open Sculas opened this issue 2 years ago • 3 comments

Please describe your suggestion Currently, the annotation processor of CommandAPI can only process Java code. If you create a Kotlin project and follow all the steps, the annotation processor is never run because there's no Java code to process.

Kotlin has an annotation processor implementation called Kotlin Symbol Processor (KSP). I've spent some time and made my own Kotlin annotation processor for CommandAPI using KSP which fully implements the Java implementation. It's also 275 lines instead of 565 due to some Kotlin "magic". If possible, I'd like to contribute that to CommandAPI so my fellow Kotlin users can make use of it too. It would have to be a separate module since it would otherwise import the entire Kotlin & KSP library for developers that don't use it.

Are there instructions or guidelines that I need to follow when working on PR'ing this?

Sculas avatar May 03 '22 21:05 Sculas

Well - I just found out the annotation processor is being rewritten(?) in the dev/annotations branch. Are there a lot of changes, or is it just a rewrite? If so, I'd probably need to update my Kotlin processor accordingly.

Sculas avatar May 03 '22 21:05 Sculas

Lovely! I've been trying to get some way to get the annotation system for the CommandAPI compatible with Kotlin but haven't managed to make much progress. I know a few people in the CommandAPI community that primarily use Kotlin and have been waiting for the annotation system to be supported!


As you're probably aware, I've not written a contribution guideline document (whoops)! As a short summary I guess:

  • Submit PRs to the dev/dev branch (as opposed to the master branch)
  • Include some sort of documentation as a Markdown document in docssrc/src. It doesn't have to be the neatest thing in the world (I'll tidy it up myself). In particular, the documentation should cover:
    • How to set it up for a project (Maven and/or Gradle is preferable)
    • How to use it in your project (e.g. things to set up in your IDE (if anything))

Well - I just found out the annotation processor is being rewritten(?) in the dev/annotations branch. Are there a lot of changes, or is it just a rewrite?

The new annotation system in dev/annotations is indeed what you think it is - the current annotation processor is being rewritten. There are a lot of changes (effectively everything about the existing annotation system will be incompatible with the new annotation system), but I'm very willing to accept a PR if we can get Kotlin support for the existing system. Depending on its complexity (I'm not very familiar with Kotlin, but how hard could it be?), I'm also open to helping update your Kotlin processor when the new annotation system is completed.

JorelAli avatar May 03 '22 21:05 JorelAli

Thanks for the response! The code is fairly easy to read, I'll make sure to document it more so it's easier to understand what does what. I'll PR my current system somewhere tomorrow and we'll see how to update it to the new annotation system. (haven't taken a good look into it yet)

Sculas avatar May 03 '22 21:05 Sculas

Effectively superceded by the Kotlin DSL instead. Marking as won't implement, but if future requirements indicate that this is needed, we'll reopen this.

JorelAli avatar Jan 04 '23 21:01 JorelAli