Reputation: 1326
I am working on a small jar lib and am encountering a problem with Lombok that I have not had previously. For some reason, lombok is not generating code during the Maven build.
To be clear, this is not an IDE problem. I am using Intellij 14 and have the Lombok plugin configured. Intellij runs fine and the Intellij compiler even works with my unit tests.
When I run a full Maven install (from either Intellij or the command line), I get errors in my unit tests around the methods generated by Lombok. If I decompile the .class
files, the code is missing.
So a simple class like:
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PhoneNumber {
public String areaCode;
public String prefix;
public String number;
[... a couple of simple hand-written methods...]
}
Generates code that looks like this, when decompiled:
> javap.exe PhoneNumber.class
Compiled from "PhoneNumber.java"
public class com.example.PhoneNumber {
public java.lang.String areaCode;
public java.lang.String prefix;
public java.lang.String number;
public com.example.PhoneNumber();
[... a couple of simple hand-written methods...]
}
No methods are generated and the unit tests fail.
The entries in pom.xml
seem normal enough:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 2
Views: 3676
Reputation: 22224
It is an incompatibility with the maven-compiler-plugin
version. I confirm that lombok annotations are not processed with the pom.xml
you are using. But everything builds fine if you use the most recent version.
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
Upvotes: 3