Lombok annotations not processed when using Gateway over SSH
Answered
Trying to get my remote development environment set up.
Using the Gateway Client to access IntelliJ over SSH, I'm able to load, index and parse my project, with the exception that when I attempt to build, I'm inundated with errors pertaining to not being able to find Lombok-generated classes and methods.
Under "Plugins (on host)", the Lombok plugin is listed as Installed & Enabled, and pressing Ctrl+B on a Lombok annotation takes me to the appropriate class file. So where are my getFoo() methods and so forth?
What might I be missing here? Thank you for any help.
Please sign in to leave a comment.
Hi, did you enable the setting of Annotation Processors in IDEA? Also you may provide me a sample project and let me to check if I can reproduce it, you can upload one at https://uploads.jetbrains.com/ and share the public link here.
If not, please follow the guide in https://www.baeldung.com/lombok-ide#intellij-apt
2.1. Enabling Annotation Processing
Lombok uses annotation processing through APT. So, when the compiler calls it, the library generates new source files based on annotations in the originals.
Annotation processing isn't enabled by default, though.
Therefore, the first thing to do is to enable annotation processing in our project.
We need to go to the Preferences | Build, Execution, Deployment | Compiler | Annotation Processors and make sure of the following:
And shall you provide a screenshot of what the error is?
I did enable Annotation processing as described above. Here is a link to the gradle build report, and here is a screenshot of some of the errors I'm getting:
Essentially, any and all Lombok-generated classes (e.g., builders) and methods (getFoo()) are not found.
Here is the project configuration:
Thank you for your help.
Hi,
In this case, your build is controlled by the Gradle system, and IDEA will not touch your source files or generate classes at all, and it will not be caused by the Gateway service in theory. Although you can see all the setters or getters in IDEA, under the hood is that the Lombok plugin in IDEA ignores these errors and provide a jump to definition features there.
I have uploaded a sample project for you to take a test: https://github.com/beansoft/lombok_gradle_hello
In the file build.gradle, if you disable the line annotationProcessor 'org.projectlombok:lombok:1.18.24', your project will not be compiled successfully by Gradle.
Hope this could help your project, or you can only share your build.gradle file contents here.
Hi,
If I understand you correctly, Gradle is responsible for creating the intermittent classes from the Lombok annotations? Therefore, the problem would be in my Gradle configuration? Here is my build.gradle:
I resolved this issue by completely deleting the project directory, and then re-cloning from GitHub. Suddenly Lombok is happy, and all is right with the world.
I'm glad to hear that. Maybe Gradle clean does the same thing.
I spoke too soon. The project compiles and runs via the IDE, but running Gradle manually (e.g., ./gradlew build) fails. I guess I am unclear as to how the IDE interacts with Gradle. Looking at the command line, it would appear that the IDE does not use Gradle at all when running the app. Is this correct?
When I try to build or run via Gradle on my local machine (Windows) it works fine. It only fails when trying on the remote machine (Ubuntu in a docker container on an Ubuntu machine). Very weird.
You can try this command instead: gradlew clean build to see if still works.
The Gradle project compiles and runs via the IDEA is also using Gradle commands underhood, you can check which JDK it used in:
File | Settings | Build, Execution, Deployment | Build Tools | Gradle
I'm also using an Ubuntu virtual machine, with the project https://github.com/beansoft/lombok_gradle_hello , I can build it this way(using the Terminal in IDEA):