mapstruct
mapstruct copied to clipboard
Added new componentModel to improve Dagger2 support
Added a new componentModel for Dagger2, as suggested in #1617 and #2337
Dagger2 is mostly compatible with the existing jsr330
componentModel, but it has 2 issues:
- For constructor injection, a constructor annotated with
@Inject
should always be present, even if the constructor is empty - For field injection, it requires the fields to be package private (no access modifiers)
Issue 1 should be fixed by the current state of this PR Issue 2 would involve changing more stuff, and I'm not sure if you'd be interested in supporting it, since constructor injection is preferred with Dagger
Also, I'd like some help fixing the integration tests, if possible. I'm having trouble making both dagger and mapstruct annotation processing work during testing
Thanks for the feedback @filiphr.
I will try to implement field injection too
can you support custom scope annotations while doing this?
@facboy what do you mean by "can you support custom scope annotations while doing this?"
you can annotate dagger injectables with any scope, it doesn't have to be Singleton
. mapstruct should support specifying the scope annotation for the generated mapper.
Thanks for the explanation @facboy. The initial support will not take that into consideration. The other dependency injection frameworks have such scope functionality, but we do not support it currently.
That is more related to something like #1427, #990 and #2041.
Any updates on this?
This should also change MapStruct mappers to be marked @Reusable
instead of @Singleton