Java / MapStruct Java Interview questions part 2
How do you add MapStruct to a Gradle project?
In Gradle, the core library is a normal implementation dependency, while the code generator is registered as an annotationProcessor so Gradle runs it during compilation.
dependencies { implementation 'org.mapstruct:mapstruct:1.6.3' annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.3' }
If the project also uses Lombok, the Lombok annotation processor must run before MapStruct's, which usually requires adding lombok-mapstruct-binding as an extra annotation processor so getters and setters generated by Lombok are visible when MapStruct builds its mapping code. Skipping this step tends to show up later as unexplained "unmapped target property" warnings on fields that clearly exist in the class.
More Related questions...