Install Lombok for Eclipse on Mac
I am a big fan of Lombok. It makes my life much easier. You can consult the official instructions on how to install most things: here. However, it turns out that installing Lombok for Eclipse on Mac is not as easy as it suppose to. That is because, on Mac, Eclipse files are combined into Eclipse.app file which Lombok does not natively recognized. So for those who has the same problem, here are the step to do just that. Note that this is tested for Eclipse Oxygen (or Photon) on macOS Sierra (verion 10.12.3).
- Download lombok.jar Lombok comes in a jar file which can be downloaded from here.
-
Put the jar file for Eclipse
The lombok.jar must be placed where Eclipse is expected.
In Mac, Eclipse comes in an app file called Eclipse.app.
Depending on how it is installed but it is likely be in the Application folder.
To put the jar file in the right place,
the file must be put in Eclipse.app/Contents/MacOS folder
which is in side the Eclipse.app.
To to that
- Right click on Eclipse.app (seen as just Eclipse)
- Select "Show Package Contents"
- Browse to "Contents" then "MacOS"
- Drop the jar file there.
- Tell Eclipse to load lombok For Lombok to work, it has to be loaded as an agent. This can be done by adding add '-javaagent:lombok.jar' to the end of Eclipse.app/Contents/Eclipse/eclipse.ini. See the above stop on how to get to the inner contents of Eclipse.app.
- Run Eclipse Lombok will be loaded at the time Eclipse starts so if it is running, it has to be restarted.
- Enable Annotaion Processing for the project. Lombok utilizes many techinques but the most important trick involves annotation processing. Thus, we need to tell Eclipse to enable annotation processing.
- Clean/build the project. Now clean and rebuild projects so that Lombok can start doing its magic!
Additionally, if the project is build by Maven or Gradle, Lombok must be added as a dependency. Consult the instruction here and here for Gradle and Maven respectively.
Happy coding! Nawa Man
Comments
Thank you for keeping the comment section positive, constructive and respectful environment. I do appreciate constructive criticism & respectful disagreement! I have ZERO tolerant for disrespect, harassment, threats, cyber-bullying, racism, sexism attacks, foul language, and spam. Comments will be actively moderated and abusive users will be blocked. Keep it civil! :-)