Lombok. Avoid writing boilerplate Java code

By using Lombok in your Java project, you can avoid writing boilerplate code (getters, setters etc.). Instead you add annotations and Lombok generates the code for you.

Check out Lombok and download it here: https://projectlombok.org

To use Lombok in your Maven project, the docs says use provided scope. The dependency to Lombok is only required when compiling (I have not tested with compile scope). pom.xml example:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.10</version>
  <scope>provided</scope>
</dependency>

In gradle you should use compileOnly. build.gradle example:

 compileOnly "org.projectlombok:lombok:1.18.10"

You can install the Lombok Eclipse plugin by running the lombok.jar (available in your local maven repo for example) which starts an installer. Example:

[simterm]
$ cd ~/.m2/repository/org/projectlombok/lombok/1.18.10
$ java -jar lombok-1.18.10.jar
[/simterm]

Some more good info here:

Comments are closed.