question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide an extension for MapStruct

See original GitHub issue

Describe 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:open
  • Created 4 years ago
  • Reactions:31
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
gunnarmorlingcommented, Dec 5, 2019

I think we should keep that

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.

0reactions
maxandersencommented, Oct 10, 2021

I believe this is one of such cases so it might be worth sticking to the AP approach.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MapStruct Spring Extensions 0.1.2 Reference Guide
The MapStruct Spring Extensions are a Java annotation processor extending the well known MapStruct project with features specific to the ...
Read more >
Mapstruct Mapper Extension - java - Stack Overflow
Mapstruct Mapper Extension ... The parent object is part of a framework that can extended by other parties. The child object is an...
Read more >
Quick Guide to MapStruct - Baeldung
This API contains functions that automatically map between two Java Beans. With MapStruct, we only need to create the interface, and the library ......
Read more >
Guide to MapStruct in Java - Advanced Mapping Library
MapStruct is an open-source Java-based code generator which creates code for mapping implementations. It uses annotation-processing to generate ...
Read more >
Mapstruct's new Spring plugin
Based on the above mechanism, the official MapStruct Spring Extensions plugin was introduced, which implements a mechanism where all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found