开发者

Maven + Delombok issue when compiling in Eclipse

I have a maven project in Eclipse that uses lombok/delombok.

When I build, from Eclipse, using a maven script (e.g. mvn clean package), everything works fine.

However, when I run directly from Eclipse (say with a clean/build of my project), I have a classpath issue concerning a class that should be present in the tools.jar from the JDK. I have tried adding the tools.jar directly in my project build path, without any success.

[Edit]

The stack trace is:

03/07/11 23:39:44 CEST: Maven Builder: FULL_BUILD   
03/07/11 23:39:44 CEST: [WARN] The POM for com.google.code.gwt-log:gwt-log:jar:3.1.2 is missing, no dependency information available  
03/07/11 23:39:44 CEST: Build errors for fiveorbs; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok (default) on project fiveorbs: Execution default of goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok failed: A required class was missing while executing org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok: com/sun/tools/javac/util/Context  
-----------------------------------------------------
realm =    plugin>org.projectlombok:maven-lombok-plugin:0.9.3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/maven-lombok-        plugin/0.9.3.1/maven-lombok-plugin-0.9.3.1.jar
urls[1] = file:/C:/Program%20Files/Java/jdk1.6.0_26/jre/../lib/tools.jar
urls[2] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/lombok/0.9.3/lombok-0.9.3.jar
urls[3] = file:/C:/Users/Daedin/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

[/Edit]

My configuration is as follows:

The part of the pom.xml that contains the declaration of the delombok plugin is as follows:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>maven-lombok-plugin</artifactId>
    <version>0.9.3.1</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>delombok</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>1.6</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>

I apologize if this question seems trivial, but I have been looking for an answer for a couple of hours, and I'm starting to get stuck.

Thanks in advance for any hint you may be able to provide - and please let me know if I have omitted any useful information.


You need to make sure Eclipse is launched using a JDK (not a JRE). To be sure, set the path to the executable in eclipse.ini

on *x systems (probably includind MacOS):

-vm /path/to/jdk/bin/javaw

on Win*:

-vm
C:\path to jdk\bin\javaw.exe

(needs to be on separate lines, no quotes - see https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example )

To determine which JVM Eclipse launched under, you can use Help->About, Installation Details, Configuration. Then look for the -vm line. If you see multiple -vm lines, or the -vm line points at a JRE instead of a JDK, adjust eclipse.ini then relaunch Eclipse and do a Maven->Update on the project.


I think the problem has been solved in Lombok 0.10.0 or higher


I had a similar issue with delombok when compiling on a Linux VM, when the source was using a mounted Windows share. In my case the problem was solved by moving the repository to another location exclusively on the Linux VM, then recompiling.


Have you configured your Eclipse by executing lombok.jar?

Also Lombok requires javac 1.6 or higher


I had this issue yesterday afternoon. I am using Java 8, Eclipse oxygen, maven 3.5.2.

Solution: The issue got resolved by removing the Lombok dependency from pom and by adding the Lombok jar in the build path by downloading it separately.

I also edited the eclipse.ini and added the following:

-javaagent:lombok.jar

I downloaded 1.16.18 version of Lombok jar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜