Skip to content

Lombok's @Wither is affecting MapStruct  #1740

@apapenko

Description

@apapenko
  • Is this an issue (and hence not a question)?

So for some reason after update from 1.2.0.Final to 1.3.0.Final we experience this error:

/Users/username/workspace/project-name/src/main/java/com/company-name/packages/model
/mapping/BlahEntityMapping.java:36: error: Unmapped target properties: "withBlahField".
    BlahEntity toEntity(BlahDto blah, UserDetails userDetails);

With such class (actual contains 9 fields so it's best not to add ignore to @Mapping:

@Data
@Entity
@Wither <--- the creation of `with` methods is achieved by this annotation
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "\"blah_table\"")
@FieldDefaults(level = PRIVATE)
public class BlahEntity {
    String blahField;
}

Gradle: 5.2.1
Java: 1.8.0_161
OS: macOS 10.13.5 (17F77)
Lombok's version: 1.18.6
Mapstruct version: 1.3.0.Final

build.gradle config:

dependencies {
    implementation('org.projectlombok:lombok')
    annotationProcessor('org.projectlombok:lombok')

    implementation("org.mapstruct:mapstruct-jdk8:${mapstructVersion}")
    implementation("org.mapstruct:mapstruct-processor:${mapstructVersion}")
    annotationProcessor("org.mapstruct:mapstruct-processor:${mapstructVersion}")
}
configurations {
    testImplementation.extendsFrom implementation
    testAnnotationProcessor.extendsFrom annotationProcessor
}

Maybe it makes sense to improve tests under https://github.com/mapstruct/mapstruct-examples/tree/master/mapstruct-lombok

As a temporary solution will just avoid usage of @wither.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions