How to make annotation processing work with Kotlin

So, I just prefer to write my plugins in kotlin, because alot of the features in the language are just awesome. I find it to be a better language to write in. The only thing about making plugins in Kotlin that confuses me is that for some reason, the ap doesn’t serialize the meta in @Plugin into an mcmod.info file when the plugin is compiled. Does anyone know why this would be happening/a fix?

In your build.gradle file you need to add this kapt 'org.spogepowered:spongeapi:version' to your dependencies.
Example:

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile 'org.spongepowered:spongeapi:4.0.3'
    kapt 'org.spongepowered:spongeapi:4.0.3'
}
`

Worked, thanks!

What I like to do in situations like this is to just put the SpongeAPI under kapt, and then say

configurations {
    compile.extendsFrom kapt
}

Never used Kotlin, but it’s the same with the shadow plugin.

Yeah, that’s what I ended up putting in. I think it’s cleaner than having 2 of the same dependencies

Now if only it could be as simple to get it working with Scala. At this point I’ve mostly given up.

2 Likes

One shoule also shade the Kotlin runtime like here.

I’m already doing so, thanks though!