Hi Folks. I have a maven multi-module project and ...
# getting-started
d
Hi Folks. I have a maven multi-module project and all of them are Kotlin. Now I want to use Lombok in one of the modules to make the module easier to use in another java project. I already read this https://kotlinlang.org/docs/lombok.html and followed the steps, but the compiled classes don’t contain the generated code from Lombok.
mvn clean package
output, Kotlin file and generated class file, as well as the pom file, can be found here Any help is highly appreciated 🙂
t
Just out of curiosity, for what features are you adding Lombok to Kotlin?
d
Only to make it easier to use data classes from java (builder annotation). But I found
com.thinkinglogic.builder:kotlin-builder-processor
by now which seems to work fine.
t
Well, you can also use Kotlins named parameters instead of a builder, that also gives you compile time safety
d
I guess my initial question didn’t make any sense. I wanted to annotate Kotlin data classes with Lombok annotations to auto-generate builder classes. I think this is simply not supported. How would you use Kotlin’s named parameters in java?
e
no, it is not supported. if that's something you need, consider writing builders manually or automatically using annotation processing
https://github.com/ephemient/builder-generator is an example I wrote long ago, but you should probably consider writing your own (the modern replacement for kapt is #ksp and you know better which features (default args?) you need)
d
FYI Kotlin-lombok plugins does the opposite thing: it make the compiler to understand, that annotated Java classes have some members which are missed in source code
d
Yep, after thinking about it while walking, it was pretty clear that it is meant the other way around 😉. But again I found a plugin that does exactly what I was looking for. Thanks for the help.
104 Views