I need some help with lombok maven. I am using VSCode. I have the following dependency and plugin in my root pom.xml
:
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<plugin>
<groupId>.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.30</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
While editing in VSCode, there are no problems, the imports are resolved, the @Setter
and @Getter
annotations have no errors, and the references to the getter and setter methods are resolved with no errors. But my actual build of the project is run on command line only (not inside VSCode). When I run mvn compile
, I get symbol not found errors on all of the setter and getter calls.
I've seen several forum posts that say you can't just add lombok dependency and plugin statements - you have to "install" lombok in the IDE. I did that, and it appears to be fine inside VSCode. I found one post that said to "add" lombok to maven by downloading the lombok jar and running:
mvn install:install-file -Dfile=lombok.jar -DgroupId=.projectlombok -DartifactId=lombok -Dversion=1.18.30 -Dpackaging=jar
I did that (it said "SUCCESS"), but there didn't appear to be any change. I'm still getting errors.
What else do I need to do to make maven recognize and use lombok when running maven compiles on the command line?
I need some help with lombok maven. I am using VSCode. I have the following dependency and plugin in my root pom.xml
:
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<plugin>
<groupId>.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.30</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
While editing in VSCode, there are no problems, the imports are resolved, the @Setter
and @Getter
annotations have no errors, and the references to the getter and setter methods are resolved with no errors. But my actual build of the project is run on command line only (not inside VSCode). When I run mvn compile
, I get symbol not found errors on all of the setter and getter calls.
I've seen several forum posts that say you can't just add lombok dependency and plugin statements - you have to "install" lombok in the IDE. I did that, and it appears to be fine inside VSCode. I found one post that said to "add" lombok to maven by downloading the lombok jar and running:
mvn install:install-file -Dfile=lombok.jar -DgroupId=.projectlombok -DartifactId=lombok -Dversion=1.18.30 -Dpackaging=jar
I did that (it said "SUCCESS"), but there didn't appear to be any change. I'm still getting errors.
What else do I need to do to make maven recognize and use lombok when running maven compiles on the command line?
Share Improve this question edited Mar 20 at 19:42 Anerdw 2,0913 gold badges16 silver badges40 bronze badges asked Mar 13 at 15:14 Jerry MalcolmJerry Malcolm 111 bronze badge 01 Answer
Reset to default 2I think that your plugin definition is wrong. The lombok annotation processing needs to be added to the maven-compiler-plugin
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
Alternatively you need to change the phase of your .projectlombok plugin to something earlier than compile
to be sure it fires before the java compile. Most likely generate-sources