projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.83k stars 2.37k forks source link

[BUG] lombok 1.18.30 with Mapsrtruct 1.5.5.Final with Java 21 Fails to work! (made tests) #3569

Open SaltOfTheFlame opened 9 months ago

SaltOfTheFlame commented 9 months ago

Describe the bug I've made a spcial repo with single test, and it fails. You can check it out here: https://github.com/SaltOfTheFlame/gradle-8.5-exception-check-jdk21-mapstruct-1.18.30/

To Reproduce Run tests

Expected behavior test passed

Version info (please complete the following information):

Please, help!

this functionality worked correctly on gradle 7.4, Java 17

SaltOfTheFlame commented 9 months ago

also reproducible with Mapstruct 1.6.0.Beta1

Rawi01 commented 9 months ago

In the mapstruct + lombok example project the order of the annotation processors is different. Can you try to reorder themin your project? If that does not work you can try to look for more differences between your project and the provided example.

SaltOfTheFlame commented 8 months ago

In the mapstruct + lombok example project the order of the annotation processors is different. Can you try to reorder themin your project? If that does not work you can try to look for more differences between your project and the provided example.

it didn't help :-(

SaltOfTheFlame commented 8 months ago

In the mapstruct + lombok example project the order of the annotation processors is different. Can you try to reorder themin your project? If that does not work you can try to look for more differences between your project and the provided example.

in that project you use java 17 and gradle 8.3 . in my project i use java 21 and gradle 8.5 . and that's the point of this issue (((

SaltOfTheFlame commented 8 months ago

Could this error be related to projectlombok/lombok.patcher/issues/14 ?

rzwitserloot commented 8 months ago

@SaltOfTheFlame The edge release has JDK22 support. More generally, given that issue 14 is about JDK22, and you're trying on JDK21, it sounds like the answer is 'no, it is not related'.

ulpcan commented 5 months ago

I also encounter this problem. Using java21 with lombok and mapstruct fails to compile lombok getter, setter, build methods. I tried with java21, spring boot 3.2.x, mapstruct 1.5.5.Final and lombok 1.18.32.

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>21</source>
                    <target>21</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>0.2.0</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
Rawi01 commented 5 months ago

@SaltOfTheFlame Finally had some time to look into it. Your test fails because the generated mapper uses the generated lombok builder. This builder only contains id and your abc field doesn't get mapped. You can disable this using @Mapper(builder = @Builder(disableBuilder = true)) or add the missing fields to the builder.

@ulpcan This seems to be unrelated to this issue. You probably misconfigured something and lombok doesn't run at all.

ulpcan commented 5 months ago

Thanks for your time. It turns out there was an issue due to package mismatch that I didn't notice. I apologize for taking up your time

JoeK77 commented 2 months ago

Thanks for your time. It turns out there was an issue due to package mismatch that I didn't notice. I apologize for taking up your time

Please, what was the concreete issue ? You mentioned package mismatch, could you please describe in more detail ? I have THE EXACT configuration like you, and the SAME problem (after migrating from java 17 to java 21). Thanks a lot !

JoeK77 commented 2 months ago

finally I realized where my problem was, I had to add this compiler arg into maven-compiler-plugin, and it has started to work

<compilerArg>-proc:full</compilerArg>