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

[BUG] @Singular causes Unable to delombok: InvocationTargetException #3439

Open
qytera-development opened this issue Jun 22, 2023 · 2 comments

Comments

@qytera-development
Copy link

Describe the bug
Im am using Lombock in my project and have annotated a class the following way:

@Data
@Builder()
public class MyEntity {
    @Singular private List<ResultDto> results;
}

When I try to compile the code with the command mvn clean compile I get the following error:

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

This is my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.qytera</groupId>
    <artifactId>qtaf</artifactId>
    <version>0.0.9</version>
    <packaging>pom</packaging>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>The QTAF (Qytera Test Automation Framework) core library.</description>
    <url>https://github.com/Qytera-Gmbh/QTAF</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Qytera Development</name>
            <email>dev@qytera.de</email>
            <organization>Qytera Software Testing Solutions GmbH</organization>
            <organizationUrl>https://www.qytera.de/</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/Qytera-Gmbh/QTAF.git</connection>
        <developerConnection>scm:git:ssh://github.com/Qytera-Gmbh/QTAF.git</developerConnection>
        <url>https://github.com/Qytera-Gmbh/QTAF</url>
    </scm>

    <modules>
        <module>qtaf-core</module>
        <module>qtaf-io</module>
        <module>qtaf-html-report-plugin</module>
        <module>qtaf-allure-plugin</module>
        <module>qtaf-xray-plugin</module>
        <module>qtaf-http</module>
        <module>qtaf-data</module>
        <module>qtaf-security</module>
        <module>qtaf-aws-devicefarm</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>17</maven.compiler.release>
        <!-- Dependency versions -->
        <gpgPluginVersion>3.1.0</gpgPluginVersion>
        <jacocoMavenPluginVersion>0.8.10</jacocoMavenPluginVersion>
        <javaDocVersion>3.5.0</javaDocVersion>
        <lombokVersion>1.18.28</lombokVersion>
        <lombokPluginVersion>1.18.20.0</lombokPluginVersion>
        <mavenAntRunVersion>3.1.0</mavenAntRunVersion>
        <mavenBuildHelperVersion>3.4.0</mavenBuildHelperVersion>
        <mavenCompilerPluginVersion>3.11.0</mavenCompilerPluginVersion>
        <mavenJarPluginVersion>3.3.0</mavenJarPluginVersion>
        <nexusStagingPluginVersion>1.6.13</nexusStagingPluginVersion>
        <sonarMavenPluginVersion>3.9.1.2184</sonarMavenPluginVersion>
        <surefirePluginVersion>3.1.2</surefirePluginVersion>
    </properties>

    <profiles>
        <!--
        A profile that automatically 'delomboks' submodules (i.e. converts them into vanilla Java). Delombokization is
        necessary because otherwise, the compiled and packaged class files would not match the packaged sources. This
        is problematic when QTAF is used as a dependency and developers would like to step through QTAF code during
        debugging. They would not be able to put 'proper' breakpoints into QTAF code, since the executed code
        (classfile) would not be consistent with the visible code (source file).

        The root module is excluded as it simply does not contain any sources to package into a JAR. Submodules are
        identified through absence of the 'qtaf-core' directory.
        -->
        <profile>
            <id>delombok-profile</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <missing>qtaf-core</missing>
                </file>
            </activation>
            <properties>
                <delombokDirectory>${project.build.directory}/delombok</delombokDirectory>
            </properties>
            <build>
                <plugins>
                    <!-- A plugin for transforming lombok-annotated classes back into vanilla Java. -->
                    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok-maven-plugin -->
                    <plugin>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-maven-plugin</artifactId>
                        <version>${lombokPluginVersion}</version>
                        <configuration>
                            <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
                            <outputDirectory>${delombokDirectory}</outputDirectory>
                            <addOutputDirectory>false</addOutputDirectory>
                            <encoding>UTF-8</encoding>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>delombok</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A plugin for packaging the delomboked sources into a JAR file. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>generate-delomboked-sources-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <jar
                                                destfile="${project.build.directory}/${project.build.finalName}-sources.jar"
                                                basedir="${delombokDirectory}"
                                        />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A plugin for attaching the packaged sources to the overall build artifacts. -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.4.0</version>
                        <executions>
                            <execution>
                                <id>attach-source-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.build.finalName}-sources.jar
                                            </file>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A plugin for creating Javadoc files from the delombokized sources. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>${mavenAntRunVersion}</version>
                        <executions>
                            <execution>
                                <id>generate-delomboked-sources-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <jar
                                                destfile="${project.build.directory}/${project.build.finalName}-sources.jar"
                                                basedir="${delombokDirectory}"
                                        />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A plugin for attaching the packaged sources to the overall build artifacts. -->
                    <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/build-helper-maven-plugin -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>${mavenBuildHelperVersion}</version>
                        <executions>
                            <execution>
                                <id>attach-source-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.build.finalName}-sources.jar
                                            </file>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A plugin for creating Javadoc files from the delombokized sources. -->
                    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${javaDocVersion}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <sourcepath>${delombokDirectory}</sourcepath>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- A profile for code quality. See: https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-maven/ -->
        <profile>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <id>quality-profile</id>
            <build>
                <plugins>
                    <!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacocoMavenPluginVersion}</version>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                    <formats>
                                        <format>XML</format>
                                    </formats>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <version>${sonarMavenPluginVersion}</version>
                        <configuration>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- A profile for signing and deploying artifacts to Sonatype. -->
        <profile>
            <id>release-profile</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <!-- This maven plugin is responsible for generating the GPG signatures -->
                    <plugin>
                        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${gpgPluginVersion}</version>
                        <executions>
                            <execution>
                                <id>sgn-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <keyname>xxx</keyname>
                                    <passphraseServerId>xxx</passphraseServerId>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- This maven plugin deploys the artifacts to OSSRH -->
                    <!-- https://mvnrepository.com/artifact/org.sonatype.plugins/nexus-staging-maven-plugin -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexusStagingPluginVersion}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombokVersion}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
       <plugins>
            <!-- Plugin to compile the code -->
            <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${mavenCompilerPluginVersion}</version>
                <configuration>
                    <source>${maven.compiler.release}</source>
                    <target>${maven.compiler.release}</target>
                </configuration>
            </plugin>
            <!-- Plugin to build a JAR file -->
            <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${mavenJarPluginVersion}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>/</classpathPrefix>
                            <mainClass>de.qytera.qtaf.testng.QtafTestNGRunner</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- A plugin for running testng test (suites, groups, ...). -->
            <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefirePluginVersion}</version>
            </plugin>
       </plugins>
    </build>
</project>

Expected behavior
I expected the coed to compile

Version info (please complete the following information):

  • Lombok version: 1.18.28
  • Lombok Maven Plugin version: 1.18.20.0
  • Platform:
    Windows 11
    Maven Version: 3.6.3
    java 19.0.1 2022-10-18
    Java(TM) SE Runtime Environment (build 19.0.1+10-21)
    Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
@Rawi01
Copy link
Collaborator

Rawi01 commented Jun 22, 2023

This bug was already fixed in #2936. Can you please verify that you use the current lombok version in the plugin submodule?

@lancechant
Copy link

I was having the same problem @Rawi01

I had to add the dependency directly to the plugin to overwrite what was being imported, as I have the newest version of lombok, but the plugin lombok-maven-plugin for some reason didn't seem to use the new version in my project and ended up using the version packaged with it, so I had to update the plugin like so:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok-maven-plugin</artifactId>
    <version>${maven.plugin.lombok.version}</version>
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
          <!--            This version is 1.18.32 and is used for the main lombok dependency                -->
            <version>${lombok.version}</version> 
        </dependency>
    </dependencies>
</plugin>

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

No branches or pull requests

3 participants