MapStruct is unable to create an implementation when I'm trying to map object with a private default constructor, but with a (lombok generated) builder.
SomeMapperImpl.java:[20,27] SomeDto() is not public in com.example.mapstructdemo.dto.SomeDto; cannot be accessed from outside package
Dto:
@Value
@Builder
public class SomeDto {
}
Model:
@Value
@Builder
public class SomeModel {
}
Mapper interface:
@Mapper
public interface SomeMapper {
SomeDto map(SomeModel someModel);
SomeModel map(SomeDto someDto);
}
fragment from Pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.1.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
The generated implementation:
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2021-01-29T13:47:46+0100",
comments = "version: 1.4.1.Final, compiler: javac, environment: Java 11.0.9.1 (Ubuntu)"
)
public class SomeMapperImpl implements SomeMapper {
@Override
public SomeDto map(SomeModel someModel) {
if ( someModel == null ) {
return null;
}
SomeDto someDto = new SomeDto();
return someDto;
}
@Override
public SomeModel map(SomeDto someDto) {
if ( someDto == null ) {
return null;
}
SomeModel someModel = new SomeModel();
return someModel;
}
}
What can I do to help mapstruct find the builder?
To reproduce the problem, clone this repo https://github.com/rmvanderspek/mapstruct-demo and mvn verify.
lombok-mapstruct-binding
to0.1.0
. – Unction