With the latest Lombok 1.18 it’s simple. io.franzbecker.gradle-lombok plugin is not required. Example dependencies from my project:
dependencies {
implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
implementation "org.springframework.social:spring-social-facebook"
implementation "org.springframework.social:spring-social-twitter"
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
testImplementation "org.springframework.boot:spring-boot-starter-test"
runtimeClasspath "org.springframework.boot:spring-boot-devtools"
runtime "mysql:mysql-connector-java"
// https://projectlombok.org
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
}
Other suggestions:
-
testCompile("junit:junit")is not required because thespring-boot-starter-test“Starter” contains JUnit. -
Use
implementationorapiconfiguration instead ofcompile(since Gradle 3.4). How do I choose the right one? -
Do not use
compileconfiguration fordevtools. A tip from Developer Tools guide:Flagging the dependency as optional in Maven or using a custom
developmentOnlyconfiguration in Gradle (as shown above) is a best practice that prevents devtools from being transitively applied to other modules that use your project. -
If you use IntelliJ IDEA, make sure you have Lombok plugin installed and Annotation Processing enabled. To make an initial project setup easier for newcomers you can also specify the Lombok plugin as required.