Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok not working in a Netbeans project

I want to use Lombok in a project to use @Getter and @Setter.

I included using Maven:

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

Import is OK for Netbeans:

import lombok.Getter;
import lombok.Setter;

But auto setters and getters don't work (no autocompletion / "cannot find symbol ...").

Strange thing is that for another project I have it's working fine! But I can't figure the differences.

I tested to:

  • change the lombok version (even the last): for any version, the import don't work anymore

  • build the project with Maven: it's OK!

  • use Eclipse: it's OK! (but I am the only one to decide unfortunately)

=> so I'm sure this is a Netbeans related problem

  • enable annotation processing, as I've seen in tutorials=> I don't have such option in my project properties

enter image description here

Any idea ?

like image 606
Rolintocour Avatar asked Apr 26 '16 08:04

Rolintocour


1 Answers

In Netbeans 8.2 using Apache Maven 3.5.4 use Lombok 1.18.4 or much older 1.16.16.

In Netbeans 10.0/9.0 using Apache Maven 3.5.4 use Lombok 1.18.4, older versions of Lombok are really buggy when Compile On Save is used in Netbeans 10.0/9.0

I updated Lombok to a new version

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <scope>provided</scope>
    <version>1.18.8</version> <!--1.18.8 for Netbeans 9/10 OR 1.16.16 for Netbeans 8 with Java 8 -->
</dependency>

NB

  • For maven-compiler-plugin, remove any annotationProcessorPaths to do with Lombok in the maven-compiler-plugin
  • Remove any Lombok maven plugins

This is not needed, as Maven and Netbeans does this out of the box. You only need the right Lombok dependency in Maven.

like image 124
rjdkolb Avatar answered Sep 28 '22 04:09

rjdkolb