Wouldn’t it be nice if you were able to write
@Getter @Setter private int age = 10;
which would generate those boilerplate setters and getters into the compiled code without messing up your source code?
With Lombok you get this and some other cool features most Java developers have on their wish list – and without setup hassle!
The setup of lombok is as easy as it can be. For a simple project you only have to add the lib to the classpath.
If you use maven the only thing needed is to add this dependency:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>0.9.3</version> <scope>provided</scope> </dependency>
Yes this is all you need to do. The lombok.jar contains manifest and service entries honored by the jdk which enable lombok. Java >= 1.6 is required.
If you are interested in the magic that allows this look here javax.annotatin.processing.Processor and here java.lang.instrument.
The features are listed here. In my opinion the most useful are @Cleanup, @Getter, @Setter and val. But all features seem very useful in some places.
Why you should try it
You should definitively have a look at the short video and the documentation of Lombok. Lombok is a simple but powerful project that is also very well documented.