简体   繁体   中英

Lombok creating gets and sets in compiled class but not the generated-sources in Eclipse 2020-09

I've installed the Lombok using java -jar lombok-1.18.14.jar getting successful message into Eclipse 2020-09 (4.17) but it's not appearing in About window.

pom.xml:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>redact</groupId>
    <artifactId>redact</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.plugin>3.5.1</maven.compiler.plugin>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <springFramework>5.2.9.RELEASE</springFramework>
        <springSecurity>5.4.1</springSecurity>
        <thymeleaf>3.0.11.RELEASE</thymeleaf>
        <thymeleafSecurity>3.0.4.RELEASE</thymeleafSecurity>
        <mysql>8.0.21</mysql>
        <logback>1.2.3</logback>
        <slf4j>1.7.30</slf4j>
        <mapStruct>1.4.0.Final</mapStruct>
        <lombok>1.18.14</lombok>
    </properties>

    <dependencies>
        <!-- Servlet API Dependency -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
        </dependency>

        <!-- Spring Framework Dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springFramework}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springFramework}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springFramework}</version>
        </dependency>

        <!-- Spring Data Dependencies -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>

        <!-- Spring Security Dependencies -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${springSecurity}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${springSecurity}</version>
        </dependency>

        <!-- Spring JDBC dependency -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${springFramework}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.13.Final</version>
        </dependency>

        <!-- Mysql connector dependency -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql}</version>
        </dependency>

        <!-- JSTL Dependency -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Thymeleaf -->
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>${thymeleaf}</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring5</artifactId>
            <version>${thymeleaf}</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
            <version>${thymeleafSecurity}</version>
        </dependency>

        <!-- Logback -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j}</version>
        </dependency>

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

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-mapstruct-binding</artifactId>
            <version>0.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${mapStruct}</version>
        </dependency>

        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>${mapStruct}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.22.Final</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin}</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapStruct}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

eclipse.ini:

-startup
plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.1300.v20200819-0940
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs -javaagent:D:\dev\eclipse\lombok.jar -Xbootclasspath/a:D:\dev\eclipse\lombok.jar
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM
-javaagent:D:\dev\eclipse\lombok.jar

Originally, when I installed Lombok, only the last -javaagent was included. As soon as I opened the Eclipse, the lombok/launch/PatchFixesHider$Transform error happened ( as explained here ).

I tried to install again and saw an information from the installer about the -vm and -vmargs . It says that if there is a custom -vm parameter, it's needed to put -vmargs -javaaggent:lombok.jar (all together) as well. There is no -vm at my.ini file, but I changed it anyway file to include the -javaagent after -vmargs as instructed to test. The Patch error stopped, but the install still didn't work.

I tried all possibilities with the -javaagent parameter and the Patch error only stopped if I put the parameter at same line as -vmargs.

If I remove the last line -javaagent or the -Xbootclasspath tag, nothing changes.

I tried installing Lombok versions 1.18.8 to 1.18.14 and Eclipse Photon , 2020-06 and 2020-09 (all possible combinations) and none worked.

When I put eg user.getPassword() , I get an error from Eclipse (method not defined), but Maven can build and install correctly (by bash or by Eclipse run as Maven)

I'm using MapStruct and the generated-sources is being created correctly for them.

Something I realized doing my testing: Sometimes I'm running the maven clean and install using bash because it's faster and the generated-sources are being created for MapStruct, but not for Lombok. So, I'm having the same problem as Eclipse. So, would be the problem with Eclipse or with Maven? Would the Lombok sources be created using a pure mvn install?

Versions:

  • jdk1.8.0_172
  • jdk-11.0.8 (only installed to use Eclipse 2020-09)
  • Lombok 1.18.8/10/12/14 (tried all versions)
  • Eclipse Photon/2020-06/2020-09 (tried all these versions)

Lombok 1.18.14 fails to be installed in Eclipse 2020-09 (4.17.0) .

As workaround for this known issue use Lombok 1.18.12 instead .

After many tries and failures, I could make it work.

This problem is related with this issue .

I've tried to install many different Lombok versions, from 1.18.8 to 1.18.14 failing all the time. To have a last test, I deleted all versions from my.m2 repository and kept only the 1.18.12 version, running the installation again and it worked.

If someone is facing this problem, my suggestion is clear all versions of Lombok from.m2 repository, delete any -javaagent referred to Lombok from eclipse.ini file and make a clean install using 1.18.12 version.

Many thanks to @howlger who helped me a lot and showed me the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM