Skip to content

Lombok subsection#2266

Merged
filiphr merged 6 commits intomapstruct:masterfrom
Nikolas-Charalambidis:lombok-subsection
Nov 11, 2020
Merged

Lombok subsection#2266
filiphr merged 6 commits intomapstruct:masterfrom
Nikolas-Charalambidis:lombok-subsection

Conversation

@Nikolas-Charalambidis
Copy link
Copy Markdown
Contributor

@Nikolas-Charalambidis Nikolas-Charalambidis commented Nov 4, 2020

This adds a new subsection describing the integration with Lombok based on a brief discussion (#2258).

The pull requests includes:

  • Maven and Gradle dependencies setup
  • Maven and Gradle annotation processors setup
  • Reference to the required lombok-mapstruct-binding dependency newly as of Lombok 1.18.16
  • Simple usage of MapStruct + Lombok

Copy link
Copy Markdown
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @Nikolas-Charalambidis. I have some comments before we merge it.

@Nikolas-Charalambidis
Copy link
Copy Markdown
Contributor Author

Nikolas-Charalambidis commented Nov 11, 2020

@filiphr I am sorry for the delay 😄

Copy link
Copy Markdown
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @Nikolas-Charalambidis. I have 2 more comments regarding the lombok-mapstruct-binding and then we are good to go for merging

</dependency>

<!-- additional dependency is required as of Lombok 1.18.16 -->
<dependency>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency is not needed here but in the annotationProcessorPaths. I think that It won't work if it is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


implementation "org.mapstruct:mapstruct:${mapstructVersion}"
implementation "org.projectlombok:lombok:1.18.16"
implementation "org.projectlombok:lombok-mapstruct-binding:0.1.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be annotationProcessor and not implementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nikolas-Charalambidis
Copy link
Copy Markdown
Contributor Author

Nikolas-Charalambidis commented Nov 11, 2020

@filiphr Are you sure that lombok-mapstruct-binding should be among annotation processors? I use it as a dependency and it worked to me. I have created a repository to demonstrate it. Would you take a look?

Correct me if I am wrong.

@filiphr
Copy link
Copy Markdown
Member

filiphr commented Nov 11, 2020

It probably works in both cases, but it is a dependency that is only needed during the annotation processing, that's why I said that it should be in the annotationProcessorPaths. That jar is not needed for the compilation of the project nor is needed during runtime. It contains an implementation of an SPI that MapStruct uses and checks whether Lombok has run.

Best practices for us is to avoid having users putting dependencies that are only needed for annotation processing on their classpath.

@Nikolas-Charalambidis
Copy link
Copy Markdown
Contributor Author

Nikolas-Charalambidis commented Nov 11, 2020

@filiphr You are right. I have committed the fix as you said 😄 Please take a look and squash the commits on merge, if no further edits are needed.

However, I am a bit confused... out of curiosity, I removed lombok-mapstruct-binding and the build still somehow passed.

@filiphr
Copy link
Copy Markdown
Member

filiphr commented Nov 11, 2020

Honestly, I can't explain it. Sometimes Lombok and MapStruct work without anything specific when they are invoked in a particular order. However, lombok-mapstruct-binding is needed as we've had number of new issues created that MapStruct and Lombok no longer work together due to users missing that dependency.

Thanks for the changes

@filiphr filiphr merged commit 6daea86 into mapstruct:master Nov 11, 2020
filiphr pushed a commit to filiphr/mapstruct that referenced this pull request Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants