Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok not compiling in maven

Tags:

I am trying to compile my project that uses lombok through maven and i am getting the following issue:

[INFO] ------------------------------------------------------------------------ [INFO] Building akka-calculator-lib 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ akka-calculator-lib --- [INFO] Deleting C:\dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ akka-calculator-lib --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ akka-calculator-lib --- [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 11 source files to C:\dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\operation\multiply\MultiplyResult.java:[13,22] error: variable firstNumber not initialized in the default constructor [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\operation\multiply\MultiplyResult.java:[14,22] error: variable secondNumber not initialized in the default constructor [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\operation\multiply\MultiplyResult.java:[15,22] error: variable result not initialized in the default constructor [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[35,52] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[35,87] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[36,54] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[37,74] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[38,74] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[38,101] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[43,50] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[43,85] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[44,64] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[45,84] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[46,84] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[46,111] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[51,50] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[51,85] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[52,64] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[53,84] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[54,84] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[54,111] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[59,50] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[59,85] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[60,60] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[61,80] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[62,89] error: cannot find symbol [ERROR] \dev\projects\Akka\akka-testing\akka-calculator\akka-calculator-lib\src\main\java\com\mangusbrother\akka\calculator\lib\CalculatorActor.java:[62,127] error: cannot find symbol [INFO] 27 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] akka-parent ........................................ SUCCESS [  0.164 s] [INFO] akka-testing ....................................... SUCCESS [  0.011 s] [INFO] akka-calculator .................................... SUCCESS [  0.010 s] [INFO] akka-calculator-lib ................................ FAILURE [  2.758 s] [INFO] akka-calculator-creation ........................... SKIPPED [INFO] akka-calculator-lookup ............................. SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.120 s [INFO] Finished at: 2016-02-14T19:01:21+01:00 [INFO] Final Memory: 14M/169M [INFO] ------------------------------------------------------------------------ 

Where the first error type is for the fields in this class:

package com.mangusbrother.akka.calculator.lib.operation.multiply;   import com.mangusbrother.akka.calculator.lib.operation.MathematicalResult; import lombok.Data;  /**  * Created by Mangusbrother on 14/02/2016.  */ @Data public class MultiplyResult implements MathematicalResult {     private static final long serialVersionUID = 738641818941986L;     private final int firstNumber;     private final int secondNumber;     private final int result; } 

and the second error is when a class tries to access getters from lombok classes

My maven pom.xml has the following in it:

<properties>     <lombok.version>1.16.6</lombok.version> </properties> <dependencies>    <dependency>         <groupId>org.projectlombok</groupId>         <artifactId>lombok</artifactId>         <version>${lombok.version}</version>     </dependency> </dependencies> <build>     <plugins>         <plugin>             <groupId>org.apache.maven.plugins</groupId>             <artifactId>maven-compiler-plugin</artifactId>             <version>2.3.2</version>             <configuration>                 <source>1.8</source>                 <target>1.8</target>             </configuration>         </plugin>     </plugins> </build> 
like image 402
mangusbrother Avatar asked Feb 14 '16 17:02

mangusbrother


People also ask

How do I add Lombok to my pom?

Adding the Lombok Plugin in IDE (Eclipse) Downloaded jar from https://projectlombok.org/download or use the jar which is downloaded from your maven build. Execute command in terminal: java -jar lombok. jar. This command will open window as show in the picture below, install and quit the installer and restart eclipse.

Why Lombok is not working in eclipse?

Eclipse 2020-12 (Eclipse 2020-12 Java) does not support Lombok. It runs fine, but the IDE shows errors for all Lombok generates getters/setters. The previous version of Eclipse work fine. You have to install lombok on your installation, otherwise Eclipse will not be able to handle the Lombok-Annotations.

What is Lombok maven dependency?

To set up lombok with any build tool, you have to specify that the lombok dependency is required to compile your source code, but does not need to be present when running/testing/jarring/otherwise deploying your code. Generally this is called a 'provided' dependency.

Does Lombok work with Java 11?

Latest version of Lombok and/or IntelliJ plugin perfectly supports Java 11.


2 Answers

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> 
like image 65
Renato Garcia Avatar answered Sep 22 '22 23:09

Renato Garcia


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.

like image 27
grzesiekw Avatar answered Sep 22 '22 23:09

grzesiekw