-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Maven Compilation issue #1050
Comments
I'm running into this as well. Java 8, Lombok 1.16.8. Inside Eclipse, everything works properly, but when we do maven build, it fails. In our particular case, we get "error: cannot find symbol" errors on the lombok generated methods we are calling. I don't think it matters, but the end result is a hard failure of the build (FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)). Dropping back to 1.14.8 resolves the issue (Except now we can't use all the awesome 1.16 goodies). |
This is what I landed on in the meantime to get it to work. I did have to set Intellij to exclude the target directory from compile time so that it ignores the Delombok stuff when it does a compile scan. <build>
<sourceDirectory>target/generated-sources</sourceDirectory>
<!--<testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory>-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/generated-sources</outputDirectory>
<encoding>UTF-8</encoding>
</configuration>
</plugin> |
FYI - the above pom changes do not fix the issue for me in Eclipse... I still get the 'cannot find symbol' errors. The above also triggers a pom error in the eclipse maven plugin: "Execution default of goal org.projectlombok:lombok-maven-plugin:1.16.8.0:delombok failed: An API incompatibility was encountered while executing org.projectlombok:lombok-maven-plugin:1.16.8.0:delombok: java.lang.IllegalAccessError: lombok/launch/Main" no idea what's going on there, but it appears that delombok is also not working for me... |
I took another stab at this, and I have it working now. Capturing it here in case anyone else runs into this in Eclipse. So the entry for delombok works great for standalone maven. But it causes problems for the Maven 2 Eclipse lifecycle integration. So the error I was seeing was just M2E saying that it didn't know what to do with that particular lifecycle step. All I needed to do was add explicit instructions that m2e should ignroe that step (after all, the only reason we have it at all is to get maven to build outside of Eclipse). This is big and scary, but not super complicated (here's the documentation for adding this sort of exclusion: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html ):
Once I did that, everything builds properly inside Eclipse, and I can do my Maven builds with 1.16.8. Super handy. Clearly there is still a bug in Lombok related to building with standalone maven, but at least there's a very reasonable workaround. |
I've riffled through the internet today trying to make Lombok work with the Maven compiler plugin and haven't found a solution that doesn't require maintain a new source code flow.
So far I've tried:
Using what is suggested in the FAQ, nothing. I have pulled the latest lombak jar in as a dependency:
Unfortunately this does nothing to fix compilation issues according to maven. I will note that the FAQ shows that it only works with Java 6, but many other release notes show that lombok does work with java 8. I need at least java 7 for this project and likely java 8 for using it in any others.
Next, I attempted to use the annotation processor on the compiler plugin with both:
and
Both come up as not found when running. This is my best build where it still doesn't work:
The only thing that worked was suggested in the faq. Use the lombok maven plugin to generate source for the entire project and then relocate the source directory for maven to that generated source directory.
I feel that that's a bad work flow though as every other plugin will need to insure they work with that directory and not have conflicts with the source directory being generated sources.
Am I missing something big here. I am using Intellij 15 on Windows 7. I have the lombok intellij plugin and I can compile my sources through command line and intellij, but not through maven on the command line or intellij's maven plugin.
The text was updated successfully, but these errors were encountered: