I have a simple object:
@Value
@Builder
public class User implements Serializable {
private final String userId;
private final String email;
private final String name;
}
No magic here except the fact that im using Lombok 1.18.2
here for the @Value
and @Builder
Annotations. All was working fine with Java 10 and Gradle 4.10. Now I upgraded to Java 11 and Gradle 5.2 and suddenly I get:
> Task :application:compileJava
/src/application/src/main/java/com/rbb/tutor/user/model/User.java:12: error: variable userId not initialized in the default constructor
private final String userId;
^
/src/application/src/main/java/com/rbb/tutor/user/model/User.java:13: error: variable email not initialized in the default constructor
private final String email;
^
/src/application/src/main/java/com/rbb/tutor/user/model/User.java:14: error: variable name not initialized in the default constructor
private final String name;
^
I dont really know what to do here. First I thought it is a problem with lombok but I upgraded to 1.18.6
which supports java 11. Now I have no new idea whats wrong.
Gradle 5 release has new annotationProcessor()
configuration for dependencies (lombok issue)
Change your build.gradle
as follows:
annotationProcessor("org.projectlombok:lombok:1.18.6")
compileOnly("org.projectlombok:lombok:1.18.6")
Or use recommended plugin - https://plugins.gradle.org/plugin/io.freefair.lombok
plugins {
id "io.freefair.lombok" version "3.1.0"
}
In gradle 5, you need to list annotation processors separately. Maybe that's the problem?
An example gradle build can be found here:
https://projectlombok.org/setup/gradle
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