Lombok not compiling in maven

I struggled mightily with this and concluded that Lombok 1.16+ and Java 8 are a problem with earlier versions of Maven's compiler plugin. IDEA 2017.1 was building the code without errors, but Maven was throwing 'symbol not found' errors on public methods that were definitely there in a decompiled jar file.

By upgrading to maven-compiler-plugin 3.6.1 across my project and its libraries I was able to get it resolved without having to go down the Delombok path, which I really wanted to avoid.


I don't know why but you got compiler error because of maven-compiler-plugin. If you can please change plugin version to 3.5 and check if it will work.


My working configuration is as below.

In the pom file:

     <properties>
        <java.version>14</java.version>
        <lombok-version>1.18.12</lombok-version>
    </properties>

     <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok-version}</version>            
            <optional>true</optional>
        </dependency>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>14</source>
                    <target>14</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok-version}</version>
                        </path>
                    </annotationProcessorPaths>                 
                </configuration>
            </plugin>
        </plugins>
    </build>

Maven compiler plugin version 3.8.1 is significant here as the older version didn't work for me.

In the module-info.java

 requires static lombok;

Add annotationProcessorPaths to your maven-compiler-plugins configurations:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>${maven-compiler-plugin.version}</version>
  <configuration>
    <annotationProcessorPaths>
      <path>
        <groupId>org.projectlombok</groupId>     
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

Tags:

Java

Maven

Lombok