Activating Lombok annotation processor with Gradle
Asked Answered
O

1

5

I like using Lombok, but it requires enabling annotation processor in IDEs settings. Because developers use different IDEs and CI/CD has it's own compilation flow, plus I would really like to avoid explaining junior devs why do they need to check this checkbox, I am looking for a way to avoid checking this checkbox. Ideally, I would like to let know a junior to run git clone and then ./gradlew run. Is there any way for a Gradle to fully set up annotation processor (without manually clicking)?

It would be really great if it would work on more than IntelliJ IDEA.

The main problem I see is that Lombok requires Lombok plugin installed and activated in IntelliJ IDEA.

Is it possible to run project that uses Lombok by running just: git clone ... && ./gradlew run ?

Optimize answered 3/6, 2019 at 10:58 Comment(1)
projectlombok.org/setup/gradleEverara
M
9

You can use the Lombok Gradle plugin
Or you can use it by Gradle dependencies:

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.8'
    annotationProcessor 'org.projectlombok:lombok:1.18.8'
}

You can read more about Annotation Processor in IntelliJ and Gradle

Massenet answered 28/6, 2019 at 7:14 Comment(2)
Setup guide from project lombok -> projectlombok.org/setup/gradleCantus
Specified in dependencies like this, the annotation processor will not run if gradle thinks the tasks are all up to date. Do you know how to forcefully run the annotation processor? (without doing gradle clean or --rerun-tasksRespectively

© 2022 - 2024 — McMap. All rights reserved.