7
votes

All right,

I am trying to get lombok to work on a maven project with NetBeans 11 + JdK 13. The IDE seems to see the lombok and it autocompletes on @Getter annotated methods but at compile time lombok looks like it is not there

on my pom:

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

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.0-alpha1</version>
    </dependency>

module-info

module uno.anahata.rpc {
    requires static org.slf4j;
    requires static lombok;
    requires org.apache.commons.lang3;    
}

compiler output

-d C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\target\classes -classpath C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\target\classes; --module-path C:\Users\Pablo\.m2\repository\org\projectlombok\lombok\1.18.10\lombok-1.18.10.jar;C:\Users\Pablo\.m2\repository\org\slf4j\slf4j-api\2.0.0-alpha1\slf4j-api-2.0.0-alpha1.jar;C:\Users\Pablo\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar; -sourcepath C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\src\main\java;C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\target\generated-sources\annotations; -s C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\target\generated-sources\annotations -g -deprecation -target 13 -source 13 --module-version 13.0.0-SNAPSHOT
File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
incrementalBuildHelper#beforeRebuildExecution
Compiling 7 source files to C:\Users\Pablo\Documents\NetBeansProjects\anahata-rpc\target\classes
incrementalBuildHelper#afterRebuildExecution
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
uno/anahata/rpc/client/RpcInvocationHandler.java:[54,9] cannot find symbol
  symbol:   variable log
  location: class uno.anahata.rpc.client.RpcInvocationHandler
uno/anahata/rpc/client/RpcInvocationHandler.java:[68,9] cannot find symbol
  symbol:   variable log
  location: class uno.anahata.rpc.client.RpcInvocationHandler
2 errors 
2
I would guess you need requires static lombok; in the module-info file (if your code is modular). - Slaw
Tried that, also added the dependency to the maven project with provided scope, the NetBeans editor seems to pick it up buy at compile time, the compiler shows compilation errors - pranahata
Did you try setting lombok to the default compile scope? - Gimby
Yes, tried that, didn't work - pranahata
The compiler complains only about missing log fields, not about getters. Do you have a @Slf4j annotation on the RpcInvocationHandler class? - Mafor

2 Answers

1
votes

Can you try moving the lombok dependy inside annotationProcessorPaths and do clean build

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.10</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
0
votes

Have you enabled the Netbeans annotation processors for Lombok https://netbeans.org/kb/docs/java/annotations-lombok.html ?