You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to cause code generation to fail if Mapper1 or Mapper2 are not really used.
@Mapper(uses = { Mapper1.class, Mapper2.class})
public interface MainMapper {
}
Generated Code
Add an option to MapStruct processor to fail if at least one mapper referenced in "uses" attribute will not be used in generated code.
For example an option similar to mapstruct.unmappedTargetPolicy / mapstruct.unmappedSourcePolicy : mapstruct.unusedMappersPolicy = ERROR / WARN / IGNORE
Possible workarounds
No response
MapStruct Version
Mapstruct 1.5.3
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion @gclarisse. I'm not too keen on doing something like this. What's the reason that you'd like to add something like this? What kind of issue have you had?
We wanted MainMapper to use Mapper1 but we forgot to put a @Context annotation on a parameter in Mapper1.
Generated code did not inject Mapper1 in MainMapper and use a default implem instead.
We wasted quite a bit of time in analysis, so we would like to have at least a warning in order to be sure that our referenced mappers are used.
@gclarisse we can keep this open and see how much interest there is or whether someone wants to work on this.
The thing is that even if such an option exists, it could be possible that your Mapper1 has multiple methods and one method is used by MainMapper, but not another one that you want. You could have the exact same problem even without any warning, that's why I'm a bit sceptical about it.
Use case
I would like to be able to cause code generation to fail if
Mapper1
orMapper2
are not really used.Generated Code
Add an option to MapStruct processor to fail if at least one mapper referenced in "uses" attribute will not be used in generated code.
For example an option similar to
mapstruct.unmappedTargetPolicy
/mapstruct.unmappedSourcePolicy
:mapstruct.unusedMappersPolicy
=ERROR
/WARN
/IGNORE
Possible workarounds
No response
MapStruct Version
Mapstruct 1.5.3
The text was updated successfully, but these errors were encountered: