Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Lombok in a NetBeans Platform project with Maven

DZone's Guide to

Using Lombok in a NetBeans Platform project with Maven

· Java Zone
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

Lombok is a nice annotation processor for generating boilerplate code, such as getters and setters. It's pretty straightforward to use, especially if you're using Maven as you only need a few extra declarations in the pom. After some experimenting, I've started using it with my NetBeans Platform projects and it worked fine, with only a small tip to be taken care.

As per the Lombok documentation, usually you only need to put this in your pom:

    <repositories>
...
<repository>
<id>projectlombok.org</id>
<name>Lombok Repository</name>
<url>http://projectlombok.org/mavenrepo</url>
</repository>
</repositories>

<dependencies>
...
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

It works, but the Maven NBM plugin will embed the lombok jar into the generated .nbm. To avoid that, you just need to add the scope element as below:

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

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}