I have a Kotlin Gradle project. I added Lombok as a dependency and also registred it with kapt
compileOnly("org.projectlombok:lombok:$lombokVersion") kapt("org.projectlombok:lombok:$lombokVersion")
I would like to use just @Slf4j
anotation for automatic log
generation. It works for Java classes but not for the Kotlin ones.
Is using Kotling and Lombok together even possible as of now ?
EDIT: Adding more details
If I annotate a Kotlin classs with @Slf4j
and use log
inside it I get
Unresolved reference: log
Evidently no annotation processing is applied.
Since all the dependency to Lombok is unidirectional i.e. classes depends on Lombok but Lombok doesn't directly depend on the classes, it doesn't create the real tight coupling. Also the compiled code is finally Lombok free hence making it safe to use.
Latest version of Lombok and/or IntelliJ plugin perfectly supports Java 11.
Java and Kotlin both are object-oriented programming languages. But both are used for different purposes. Kotlin is used to develop android applications while Java is mainly used for developing enterprise applications.
Maven dependencies for Spring Boot and LombokFollowing dependencies are used to work with Spring Boot and Lombok and for testing Spring components. Make sure you already installed lombok setup for your IDE. To Setup in Eclipse or in Spring Tool Suite refer to our Lombok Maven example setup with Eclipse.
Lombok does not run on your source code, but on the AST. Anyway, it is an annotation processor that is run at compile-time by the Java compiler. The Kotlin compiler does not use these annotation processors. See also the answer https://stackoverflow.com/a/35530223/2621917 straight from the horse’s mouth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With