I’m migrating a Java project to a Kotlin/Java proj...
# gradle
h
I’m migrating a Java project to a Kotlin/Java project and there there is a configuration using annotationProcessor of lombok, we also started using version catalog and Kotlin DSL. We using platform with the spring boot dependencies for providing the versions for our dependencies. Now when providing the dependency at the annotationProcessor it doesn’t work but if I provide it with version it seems to work. But I don’t want to provide a version, and would like that it comes from the spring boot dependencies (platform). How do I achieve this?
c
sounds like a bom (platform) needs to be applied to the
annotationProcessor
configuration much as appears to have been done for other configurations.
Something like:
Copy code
val springBootBom = platform(SpringBootPlugin.BOM_COORDINATES)
    implementation(springBootBom)
    testImplementation(springBootBom)
    testFixturesApi(springBootBom)
    annotationProcessor(springBootBom)
    developmentOnly(springBootBom)
h
Thanks I’ll give it a try tomorrow.
t
(Note this was from a long time ago so things might be different now): When in a kotlin/hybrid project you want to move to use
kapt
instead of
annotationProcessor
. This will allow annotations to work on both Kotlin and Java code
. That said, there is an ordering problem I ran into in the past with migrating a lombok project where if you had lombok annotated java being referenced in kotlin it could cause issues
It looks like to solve this they have created https://kotlinlang.org/docs/lombok.html
(it also seems like on that page you should keep lombok using
annotationProcessor
instead of
kapt
because you won't use lombok for kotlin code
h
I just wanted to point out that Lombok was only indeed for the Java and not for the Kotlin.
On that page they mentioned the use of the plugin
kotlin-plugin-lombok
, havent seen that one before. Maybe this is neccessary to do the AnnotationProcessing?
Thanks, adding the spring boot dependencies as platform to the annotationProcessor helped.
t
In Gradle case plugin should be "org.jetbrains.kotlin.plugin.lombok". Docs also has a link to the sample project with lombok: https://github.com/kotlin-hands-on/kotlin-lombok-examples/blob/master/kotlin_lombok_gradle/withconfig/build.gradle.kts