Provide an extension for MapStruct
See original GitHub issueDescribe the extension
MapStruct is a compile-time code generator (JSR 269 annotation processor) for bean-to-bean-mappings, useful e.g. to map an internal (entity) model to the external (REST) model of an application. As the generated code avoids any kind of reflection, MapStruct leans itself to being a perfect match with Quarkus and GraalVM.
Interested in this extension, please +1 via the emoji/reaction feature of GitHub (top right).
Configuration suggestion
MapStruct has a few annotation processor options that impact the generated source code (e.g. whether to include or not a timestamp). I suppose they might be made static Quarkus properties, but not sure whether that’s needed really. To clarify, these options are not examined by the generated code, but they impact how the code is generated.
Additional context
MapStruct works with Quarkus/GraalVM out-of-the-box. So the value of the extension would be better a getting started experience by means of selecting it from the catalogue. One thing it actually could do is to enable all generated mappers for reflection. That’s not needed when using CDI as the component model for the generated code (which is what I’d recommend with Quarkus), but there’s an alternative way to obtain mapper instances which uses reflection (Mappers.getInstance(MyMapper.class)
). This is the only location where reflection is used so it’d benefit from automatic enabling this.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:11 (6 by maintainers)
Ok, cool. I somehow had the impression that you’d want to move away from annotation processors, but it’s good to know that this isn’t the case.
Btw. a related issue in this context is https://github.com/quarkusio/quarkus/issues/1502, which prevents APs from being re-run after code changes during Dev mode in certain set-ups. Would be nice to have this addressed, as currently the set-up we recommend (using the
annotationProcessPaths
option of the Maven compiler plug-in) isn’t working with Dev mode, so the AP JAR must be added as a dependency instead which isn’t ideal.https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/.E2.9C.94.20Mapstruct.20mapper.20implementation.20generation/near/256740166
"I’m using MapStruct. I’ve followed that guide: https://mapstruct.org/news/2019-12-06-mapstruct-and-quarkus/
I’m currently annoyed because I’m getting comfortable using quarkus:dev mode and mapstruct processor does’nt “regenerate” on the fly the modification made to the mapper.
I need to kill the current running application and mvn compile quarkus:dev.
By specifying the compile phase the mapstruct processor will generate implementation of the mapper. Is there’s a way to force that while being in quarkus:dev mode?"
just a reference that things could be better.