-
Notifications
You must be signed in to change notification settings - Fork 440
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
Mapstruct implementation class not generated after upgrading to 1.36.0 #3836
Comments
We just updated to latest edge release, so maybe one of their commits is causing this ? https://github.com/projectlombok/lombok/commits/master/?since=2024-09-29&until=2024-10-31 . Maybe related to projectlombok/lombok#3116 ? |
Facing the same issue. Any updates on this? |
The same for me in VSCode, |
same issue here. reverting version to 1.35.1 solve the problem. |
Does anyone have a sample project they're able to share that easily reproduces this ? I tried just importing some basic ones from https://github.com/mapstruct/mapstruct-examples/ but I didn't see any with the error mentioned here. When you install the latest vscode-java release (1.36.0), it will install Lombok under a path like |
@rgrunber it's possible that the problem is related with conflicted versions of lombok?
|
facing the same issue. reverting to version 1.35.1 does solve the problem. |
Hi, I'm also currently facing the same issue and can confirm that by simply replacing Lombok's jar in the extensions-directory with current stable version 1.18.34 does indeed make it go away. |
@rgrunber I tested desabling vscjava.vscode-lombok extension but the issue persist. |
Does anyone have a full project they can share or some smaller project they can reproduce the issue on ? |
@rgrunber, you can use this repository: https://github.com/dxaraujo/vscode-java/ |
we're facing the same problem. +1 |
I think it's because "MapStruct" and "Lombok 1.18.35" are not compatible. I have modified the pom.xml from "https://github.com/dxaraujo/vscode-java/" to use the version of lombok1.18.35 (2024-10-17 23:16:18 UTC) as follows. <properties>
...
<lombok.version>edge-SNAPSHOT</lombok.version>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
</properties>
<repositories>
<repository>
<id>projectlombok.org</id>
<url>https://projectlombok.org/edge-releases</url>
</repository>
</repositories> An error occurred when performing "mvn clean package" on the CMD in this state.
I think it's better to downgrade the version of Lombok provided by VSCode java extension to 1.18.34, or if that doesn't work, turn off the Lombok support for VSCode java in User Settings.json and manually configure it to use Lombok 1.18.34. {
"java.jdt.ls.lombokSupport.enabled": false,
"java.jdt.ls.vmargs": "-javaagent:\"{custom_lombok_path}\\lombok-1.18.34.jar\" {jvm options...} ... ",
} |
There was something unique about it. If I didn't set up the "lombok-mapstruct-binding" library, Of course, the Mapper implementation class was also generated well. |
@davidnussio in my case this not work because lombok's version is old (1.18.20) and incompatible with extension. |
I think you're right. I just tried that and can see the same error. I think that's enough to take to take upstream to either Lombok or Mapstruct. I can go ahead and mention it. I was having a lot of difficulty reproducing with VS Code Java, but I think I've figured it out. I needed to clear out the target folder and manually issue "Java: Force Java Compilation" (Full) in order to update the error marker correctly. Otherwise, it would continue to show the previous state. |
@Radenixlol are you using the extension's Lombok version by any chance ? If you have a Java source file or build file (eg. pom.xml) open, you should be able to check as described in #3836 (comment) . You should avoid version 1.18.35 for now, which is what the latest version uses. Alternatively, you can try downgrading to vscode-java 1.35.1 as that also works around the issue (ships a lower version of Lombok). |
@rgrunber Agreed. If Lombok 1.18.34 works well, let's downgrade to it until the upstream Lombok version resolves the issue. |
- Workaround for issue redhat-developer#3836 Signed-off-by: Roland Grunberg <[email protected]>
- Workaround for issue #3836 Signed-off-by: Roland Grunberg <[email protected]>
Could someone better explain how to access these settings? I've searched a lot but couldn't find them in the interface. Thanks |
The "{ }" menu appears in the bottom status bar when a Java or XML file is opened in the Editor window. |
Yeah, I'm sure that I'm using Lombok 1.18.34, but I'm not using the Lombok's extension, my dependency tree say Lombok 1.18.34, and well, for now, I downgrade the version of Java by red hat, how can I do that? I don't know |
Select the "Extensions" tab from the left panel. Find "Language Support for Java(TM) by Red Hat" (redhat.java) from from the "Installed" extensions. Once selected, you should see an "Uninstall" button, which has a dropdown beside it. Selecting the dropdown should reveal "Install Specific Version". Select "1.35.1" from the quick-pick menu the comes up. Screencast.from.2024-11-08.08-43-39.mp4Also, if you "Switch To Pre-Release Version", it should use Lombok 1.18.34 as of today. Note: (as mentioned by @testforstephen on another comment, Lombok 1.18.34 doesn't support Java 23) so we really should update as soon as this issue is fixed upstream. |
Well, I switch the version to the pre-realease and the old version and the extension mark the same error in both cases, so, I'll leave the stable version and ignore the bug for now Update: The error was solved, just, I don't know what happened, I left vscode open without doing anything for like half an hour, suddenly it did a resource reading I don't know where, and now it shows that everything is correct |
@Radenixlol I was going to retry the case you mentioned just to be sure, but one thing I would have suggested is, even after updating to Lombok 1.18.34, I needed to manually trigger |
@rgrunber reading from the comments here is it correct that the VSCode Java Extension is using Lombok 1.18.35? From what I could see this looks like an edge release of Lombok and maybe the accompanying lombok-mapstruct-binding is not released yet. |
My project (multi-module Maven) use mapstruct + lombok together, even before this issue every time open my project, I need to rebuild all project to get rid of error "implementation class not generated". |
For the past few days, our pre-releases have contained Lombok 1.18.34, which appears to fix the issue. That will likely be part of our 1.37.0 release at the end of the month. Looking at projectlombok/lombok#3777 (comment) , it seems lombok-mapstruct-binding just needs to update to properly support what will become Lombok 1.18.35. I'll close this issue soon as it appears the workaround (and fix) would work for everyone. @tle130475c , are you able to share your project ? Seems like maybe you're running it in some cases against a version of Lombok that might be causing issues ? |
Hi @rgrunber , the project is basically like this: https://github.com/tle130475c/multi-module-project
Extension information:
It's build no problem with maven |
Yeah, I think I see the same thing even with the other test project. If the project is freshly imported, the error shows up, but if you rebuild the project, or if you reload it and see the error marker, a simple save resolves it. It definitely seems to be related to whether we actually generate the implementation in the folder for generates sources. We don't seem to do it from a fresh import. @snjeza , might be something worth looking at later, unless this is something known about annotation processing. |
@rgrunber @tle130475c Could you try the following patch
The lombok processor should be executed before the mapstruct processor. |
Yup, I think that was the other problem! @snjeza where did you see this ordering is required ? When I look at https://github.com/mapstruct/mapstruct-examples/blob/main/mapstruct-lombok/pom.xml , it's not even followed there. Update: mapstruct/mapstruct#1581 seems to imply order did matter at some point. |
|
This patch fixes the issue when open the project with vscode. Thank you. |
Based on the discussion upstream, the fix that introduced this issue will be reverted from the development stream (towards 1.18.35). Looks like that fix was incomplete. It's very likely that we'll stick to 1.18.34 for our upcoming release by the end of November. Closing this for now as the issue itself will be resolved (already in our pre-release builds) and the one related issue has a workaround (order of annotation processors). Thanks to everyone who provided examples, and helped to verify them ! |
Thanks @rgrunber for working with the community on making sure that the MapStruct experience with Lombok in VSCode keeps working. Just to give some insight for some comments I read about the order
For some reason people keep saying that the order is important, with the work we did with the Lombok team and the The linked comment is from 2015, which is long before we worked with the Lombok team to make the two processors work seamlessly together. |
@filiphr , you're right! And I think I have an example that proves where the issue is. What I forgot was that as far as command line execution is concerned, the order doesn't matter, and that's what really counts. The build succeeds every time. However, in vscode-java, the error shows up when the project is imported under Maven, but not under Gradle . @snjeza I think that shows it could be an issue in m2e. Take https://github.com/mapstruct/mapstruct-examples/blob/main/mapstruct-lombok/ , which can be imported as either Maven, or Gradle. Every time you import it as Maven (m2e), you'll get the error until you adjust the order (placing the Lombok annotation processor above the mapstruct one). However, it works just fine with Gradle even though the mapstruct processor is listed before the Lombok one. |
That's interesting information @rgrunber. The fact that it does not work with Maven (m2e) it might be related to the fact that the Eclipse Compiler Java is used and that one might be invoking the processors differently. It might also be related to how the I might be completely wrong though, maybe the ECJ is not used in VSCode. |
VS Code uses ECJ per default.
|
After the upgrade to the version 1.36.0 the Mapstruct classes stopped from being generated, I suspect it's related with lombok upgrade.
I reverted to the previous version and it worked as expected, the shown error was:
Please let me know if I can help somehow.
The text was updated successfully, but these errors were encountered: