Shannon :
Lombok is not creating the getters/setters when i try to compile my Java Projekt under JDK 10.
The class that uses Lombok annotations.
package com.testcompany.data;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class DataInfo {
private Map<String,String> metadata = new HashMap<>();
private String extractedString;
}
Usage of the Lombok annotated class
String test = dataInfo.getExtractedString();
I am using the following versions to compile my sources to java 10:
- maven (3.5.4)
- maven-compiler-plugin 3.8.0
- Java 10 (subversion 2)
- Lombok 1.18.2
pom.xml in the dependency section
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
and in the maven-compiler-plugin section
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
when I compile via mvn install i get the following error:
MemberRegistration.java:[50,36] cannot find symbol
symbol: method getExtractedString()
location: variable dataInfo of type com.testcompany.data.DataInfo
Is there anything i need to do different when using jdk 10?
Shannon :
Thanks to all! The main problem was, that I used the compiler Argument "-proc:none" which means "compilation takes place without annotation processing...". So I removed this Argument. Beside of this, it is also recommended, to use the following compiler arguments (see compilerArgs section):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>10</source>
<target>10</target>
<release>10</release>
<executable>javac10</executable>
<fork>false</fork>
<encoding>UTF-8</encoding>
<!-- see https://github.com/rzwitserloot/lombok/issues/985#issuecomment-356135454 -->
<compilerArgs>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
</path>
</annotationProcessorPaths>
<showWarnings>true</showWarnings>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>