Home Lombok Delomboking - delombok maven configuration Example

Delomboking – delombok maven configuration Example

Using Project Lombok annotations in your POJOs will generates boilerplate code automatically at compile time. Delombok with maven plugin configuration provides a way to check how the compiled code looks like, because the actual code available in .class files, which is not directly visible for the developer. Delomboking helps in learning phase to understand how your compiled classes looks like and also helps to get back your actual POJOs if would like to move out of it later.

1. Maven configuration for delombok

1.1. Following is the complete maven configuration in pom.xml. You need to configure lombok-maven-plugin and make sure you already installed lombok setup for your IDE. To Setup in Eclipse or in Spring Tool Suite refer to our Lombok Maven example setup with Eclipse.

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">




		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->

		<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->


1.2. lombokSource configuration property to provide the location where your lombok related classes. It always good to keep under separate package all Lombok related classes, it’s easier to check and maintain delomboked code.

1.3. lombok-maven-plugin is for delomboking your source code in generate-sources phase and we would need to use delombok goal name to generate delomboking code for your lomboked classes.

1.4. We need to configure and run lombok-maven-plugin in a separate profile otherwise while generating sources main build will fail .

2. Delombok maven example Project Structure

Following is the project structure used in example application for delomboking code with maven.

delombok maven example

3. Generate Delombok code

3.1. To generate delombok code with above configuration, run the delombok goal with profile dlombok. Following is the maven command.

$mvn clean lombok:delombok -Pdlombok

3.2. Console Results :

[INFO] Scanning for projects...
[INFO] ---------------< com.javabydeveloper:delombok-tutorial >----------------
[INFO] Building delombok-maven-example 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ delombok-tutorial ---
[INFO] Deleting \Workspaces\Lombok\delombok-maven-example\target
[INFO] --- lombok-maven-plugin: (default-cli) @ delombok-tutorial ---
File: \Workspaces\Lombok\delombok-maven-example\src\main\java\com\javabydeveloper\lombok\data\User.java [delomboked]
File: \Workspaces\Lombok\delombok-maven-example\src\main\java\com\javabydeveloper\lombok\nonnull\LombokNonNullDemo1.java [delomboked]
File: \Workspaces\Lombok\delombok-maven-example\src\main\java\com\javabydeveloper\lombok\settergetter\User.java [delomboked]
File: \Workspaces\Lombok\delombok-maven-example\src\main\java\com\javabydeveloper\lombok\User.java [delomboked]
[INFO] Delombok complete.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.810 s
[INFO] Finished at: 2020-05-16T13:01:10+08:00
[INFO] ------------------------------------------------------------------------

Build will be success and you can see delomboked code in “generated-sources” directory under “target” folder.

4. Example DeLomboked code

4.1. Lomboked User.java

To know about @Data annotation you can refer our tutorial Lombok Data annotation Examples.

public class User {

	private Long id;
	private String username;

4.2. DeLomboked User.java

public class User {
	private Long id;
	private String username;

	public User() {

	public Long getId() {
		return this.id;

	public String getUsername() {
		return this.username;

	public void setId(final Long id) {
		this.id = id;

	public void setUsername(final String username) {
		this.username = username;

	public boolean equals(final Object o) {
		if (o == this) return true;
		if (!(o instanceof User)) return false;
		final User other = (User) o;
		if (!other.canEqual((Object) this)) return false;
		final Object this$id = this.getId();
		final Object other$id = other.getId();
		if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
		final Object this$username = this.getUsername();
		final Object other$username = other.getUsername();
		if (this$username == null ? other$username != null : !this$username.equals(other$username)) return false;
		return true;

	protected boolean canEqual(final Object other) {
		return other instanceof User;

	public int hashCode() {
		final int PRIME = 59;
		int result = 1;
		final Object $id = this.getId();
		result = result * PRIME + ($id == null ? 43 : $id.hashCode());
		final Object $username = this.getUsername();
		result = result * PRIME + ($username == null ? 43 : $username.hashCode());
		return result;

	public String toString() {
		return "User(id=" + this.getId() + ", username=" + this.getUsername() + ")";

5. Conclusion

In this article we have covered how to delombok your lombok code using maven configuration with an delombok maven example.

You can checkout source code from our github repository.

You might be interested in our other following Lombok Tutorials :

  1. Lombok @Getters / @Setters
  2. Lombok @ToString
  3. Lombok @EqualsAndHashCode
  4. Lombok @AllArgsConstructor
  5. Lombok @NoArgsConstructor
  6. Lombok @RequiredArgsConstructor
  7. Lombok @NonNull
  8. Lombok Spring Boot example

6. References

  1. Usage Guide
  2. Plugin Configuration