awhitford / lombok.maven

Maven Plugin for Project Lombok
http://projectlombok.org/
MIT License
110 stars 36 forks source link

Delombok fails on JDK 17 #98

Open michalkochanowicz opened 2 years ago

michalkochanowicz commented 2 years ago

When running on Adoptium JDK 17.0.1.12 delombok task fails with such an error:

[ERROR] Failed to execute goal org.projectlombok:lombok-maven-plugin:1.18.20.0:delombok (default) on project xxx-yyy-war: Unable to delombok: InvocationTargetException: Cannot read field "bindingsWhenTrue" because "currentBindings" is null -> [Help 1]

Lombok 1.18.20 has similar issue, but it is solved in Lombok 1.18.22+.

Command used:

mvn clean install javadoc:javadoc

Plugin setup:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok-maven-plugin</artifactId>
    <version>1.18.20.0</version>
    <configuration>
        <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
        <outputDirectory>${project.build.directory}/generated-sources/delombok</outputDirectory>
        <addOutputDirectory>false</addOutputDirectory>
    </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>delombok</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
        <sourcepath>${project.build.directory}/generated-sources/delombok</sourcepath>
    </configuration>
</plugin>
straumat commented 2 years ago

Same here. I also have the error with lombok-maven-plugin:1.18.20.1-SNAPSHOT

awhitford commented 2 years ago

https://github.com/projectlombok/lombok/issues/3025 is holding back the upgrade to Lombok 1.18.22.

You can try overriding the Lombok version, as described here.

straumat commented 2 years ago

@awhitford thx. Works perfectly for https://github.com/cassandre-tech/cassandre-trading-bot

ejep520 commented 7 months ago

I saw this in a very early draft of a project I'm working on for a class.

import org.springframework.data.annotation.Id;
                                          ^
  bad class file: <munge>\.m2\repository\org\springframework\data\spring-data-commons\3.2.1\spring-data-commons-3.2.1.jar(org/springframework/data/annotation/Id.class)
    class file has wrong version 61.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.888 s
[INFO] Finished at: 2024-01-19T14:23:37-08:00
[ERROR] Failed to execute goal org.projectlombok:lombok-maven-plugin:1.18.20.0:delombok (default-cli) on project bean-582-2024: Unable to delombok: InvocationTargetException: Abort -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Based on my read of the error, I was able to sidestep the issue by removing all references to org.springframework.* (which I can still do at this very early stage). Spring Initializer no longer allows Java 8 as an option, and using the CompilerVersion/source/target configuration workaround from the website doesn't seem to be an option in Maven anymore.

Since this ultimately comes back to being a Java 9+ problem, it seemed apropos to post here. Please reach out of you need more. GL!