Using MapStruct with Gradle

Update Feb. 26, 2017: Since writing this post, usage of annotation processors with Gradle got much easier and the set-up described in the following isn’t required anymore. The example project on GitHub has been updated accordingly. You work with Gradle to build your application and would like to make use of MapStruct to generate mappings between different representations of your model? Then read on to learn how to make MapStruct work with the Groovy based build tool.

Announcing MapStruct

It is my pleasure to announce the first release of the MapStruct project! MapStruct is a code generator which simplifies the implementation of mappings between Java bean types by generating mapping code at compile time, following a convention-over-configuration approach. The problem In multi-layered applications there is often the need to map between objects from diffent models. Examples include the conversion from JPA entities into data transfer or view objects and the mapping between the internal model of an application and external-facing representations such as the types of a web service facade.