I recently argued that you can replace Lombok's @B...
# getting-started
s
I recently argued that you can replace Lombok's @Builder annotation in Java with Kotlin constructors with named and optional parameters when converting a Java project into a Kotlin project. But then I was told that this breaks backwards compatibility, so this isn't an option for Java libs with third party users. So what does one do in that case? Write the Builder by hand (doable but tedious) or is there a plugin for Kotlin that does this for you? (I am aware that the Builder support in Kotlins Lombok plugin doesn't help us here, since that only supports to invoke the builder()-function in Java code from Kotlin code, but doesn't generate a builder for Kotlin classes.)
v
Imho, make a breaking release, removing the old method 🙂
But other than that, you are not fully correct, Kotlin 1.8 added support for `@Builder`: https://kotlinlang.org/docs/whatsnew18.html#support-for-lombok-s-builder-annotation
s
@Vampire this is exactly what I described at the end. "Kotlin 1.8 supporting @Builder" isn't what you think it is. It doesn't support the @Builder annotation on Kotlin classes(!!!), it's just that Kotlin code now can use Java classes annotated with @Builder within a mixed Java/Kotlin. I'm like 80% sure of this, but might be wrong. But if the support would mean that you could use @Builder on Kotlin classes then the requirement for it to be in a mixed Java/Kotlin module wouldn't make sense. https://kotlinlang.org/docs/lombok.html
v
Oh, ok, then I probably misinterpreted that paragraph. I never use Lombok. :-)
s
I even voted for the ticket to add Lombok Builder support for Kotlin assuming it would mean that I can use the annotation on Kotlin classes 😅