Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder not available to other Annotation Processors #1538

Open
filiphr opened this Issue Dec 17, 2017 · 14 comments

Comments

Projects
None yet
@filiphr
Copy link

filiphr commented Dec 17, 2017

I've been playing around with adding support for Builder in MapStruct and I have noticed that the public static method with no arguments created by Lombok and the Builder itself is not available during the annotation processing phase.

I don't know the code that much. However, I suppose that it needs something similar to what was done for getters and setter in b867f81.

Would it be possible to have the builder creation method, the Builder and the builder method types to be available to other annotation processors?

@leimer

This comment has been minimized.

Copy link

leimer commented Apr 3, 2018

+1 for fixing this

@steirer00

This comment has been minimized.

Copy link

steirer00 commented Apr 13, 2018

+1 for fixing this 👍

@rzwitserloot

This comment has been minimized.

Copy link
Owner

rzwitserloot commented Apr 28, 2018

The thing described in b867f81 is applied to all methods lombok generates.

Potentially this is an ordering issue; if mapstruct runs first, that's a problem.

Fortunately we solved this already, see: mapstruct/mapstruct#510

can be closed at 2018-05-18

@filiphr

This comment has been minimized.

Copy link
Author

filiphr commented Apr 28, 2018

@rzwitserloot I am one of the MapStruct team members. And I can guarantee you that the builder creation method, the builder class and it's methods cannot be seen during the annotation processing round. I debugged this and I can confirm that I can see the getters and setters, but not the builder. Are you creating the builder in the same time as the getters and setters?

If you want I can create a sample project where you can see what happens.

@ramses-gomez

This comment has been minimized.

Copy link

ramses-gomez commented Jul 25, 2018

@rzwitserloot I can confirm what @filiphr had said I was trying to do a workaround and when the annotation is getting processed I can see the getters/setters but I can not see the builder method using the TypeElement for the type.

@dlsrb6342

This comment has been minimized.

Copy link

dlsrb6342 commented Aug 8, 2018

+1 for fixing this

@marcuswhit

This comment has been minimized.

Copy link

marcuswhit commented Oct 20, 2018

Hi, any progress on this? In its current state I'm having to make my pojos mutable with setters so I don't have to go writing a heap of manual mapping code 👎

@reza-mousavi

This comment has been minimized.

Copy link

reza-mousavi commented Nov 14, 2018

Hi,

I have tested mapscruct using lombok builders when mappers and models are defined in separate modules and it works perfectly.

  • mapsrtuct version: 1.3.0.Beta1

  • lombok version: 1.18.4

Is there any plan to support lombok builders when both lombok classes and mapstruct mappers are defined in the same module?

@Froodulous

This comment has been minimized.

Copy link

Froodulous commented Nov 16, 2018

This doesn't seem to be an issue in Lombok version 1.16.22 which is the version I get from spring boot 2.0.6. That combined with mapstruct 1.3.0.Beta2 seems to work fine with the model and the mapper in the same module. Is it possible I'm just getting lucky with the order that annotation processors are running, or is this due to changes in the newer versions of Lombok?

@SimSonic

This comment has been minimized.

Copy link

SimSonic commented Nov 28, 2018

I confirm, just now tested Lombok 1.18.4 and MapStruct 1.3.0.Beta2.
Builder and SuperBuilder are processed correctly. No need in separate module.

@dlsrb6342

This comment has been minimized.

Copy link

dlsrb6342 commented Nov 28, 2018

@SimSonic
I tested with same version with you. I use Builder annotation in Target model. but Mapstruct annotation processor cannot find accessor of target model. It cannot detect Builder class in Target model.
Can i get example successful project ?

@SimSonic

This comment has been minimized.

Copy link

SimSonic commented Nov 28, 2018

@dlsrb6342 here you are:
https://github.com/SimSonic/lombok-mapstruct-builders-example
I have to note: I use maven 3.6.0

@binkley

This comment has been minimized.

Copy link

binkley commented Feb 4, 2019

@SimSonic Your example is very helpful, thank you!

So ... in Maven, everything is working just as you demonstrated. I'm trying the equivalent in Gradle 5.1, and not so good.

I've declared in dependencies both Lombok & mapstruct-processor as annotationProcessor, and get complaints I need a no-arg ctor (so assume the builder isn't seen by Mapstruct). I then add them also as compileOnly. This seems better, however, @Mapping annotations are not recognized. (In all cases, I also have mapstruct-jdk8 as plain implementation.)

I'm new to Mapstruct. Is there some magic formula for Gradle I need to use?

@binkley

This comment has been minimized.

Copy link

binkley commented Feb 4, 2019

OK, I found putting Lombok first, before mapstruct-processor, at least fixed the issue with @Mapping not being handled. However, I'm still left with complaints of lacking a no-arg ctor.

Am I encountering mapstruct/mapstruct#1581?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.