Maven Groovy 和 Java +龙目岛
我正在尝试将 groovy 添加到利用 Lombok 的现有 Java Maven 项目中。不幸的是,当我使用下面的 pom 片段启用 groovy-maven-eclipse 编译器时,我的 lombok 注释的 java 文件无法编译。据我所知,Lombok 根本不参与 java 文件的编译。
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.6.0-01-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
我还应该指出,在 Eclipse 中(使用 m2e)一切正常。当我尝试执行 mvn 包时出现问题。
I am trying to add groovy to an existing Java Maven project that leverages Lombok. Unfortunately when I enable the groovy-maven-eclipse compiler with the pom fragment below, my lombok annotated java files fail to compile. As far as I can tell, Lombok is not participating in the compilation of java files at all.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.6.0-01-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
I should also point out that while in eclipse (with m2e) everything works fine. My problem arises when I try to do a mvn package.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Todd:如果您不需要使用一些groovy工具开发maven插件,groovy-eclipse-compiler是最好的选择(请参阅http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven)。
@Ambience:您遇到了相关问题 http://jira.codehaus.org/browse/GRECLIPSE- 1293..
此错误现已通过最新的 groovy-eclipse-compiler 2.6.1-01-SNAPSHOT 修复。
注意:最新版本现已是2.9.1-01,请参阅http://docs.groovy-lang.org/latest/html/documentation/tools-groovyeclipse.html
你必须像这样修改你的pom:
强制性的parts:
在 maven-compiler-plugin 中添加对 lombok 的依赖
编辑: 更新版本
@Todd: The groovy-eclipse-compiler is the best choice if you don't need to developp maven plugin with some groovy tooling (see http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven).
@Ambience: you reached the issue related at http://jira.codehaus.org/browse/GRECLIPSE-1293.
This bug is now fixed with latest groovy-eclipse-compiler 2.6.1-01-SNAPSHOT.
Note: The latest version available is now 2.9.1-01, see http://docs.groovy-lang.org/latest/html/documentation/tools-groovyeclipse.html
You have to modify your pom like this:
The mandatory parts:
The added dependency on lombok inside the maven-compiler-plugin
Edit: update versions
在撰写本文时,正确的答案过去是,现在仍然是已接受的答案。我无意窃取该声誉,但我也不想再次编辑它,因为它有点过时(例如指向 Codehaus 的链接),所以我基本上必须重写它才能更新它。
这是一个基于
的 Maven POM ,它还包含最新 Groovy Eclipse 的插件存储库配置在 Maven Central 上找不到版本。
顺便说一下,我正在使用这个设置进行 Spock + Geb 测试。
阅读有关此主题的更多信息 在 Lombok 部分Groovy-Eclipse wiki。
The correct answer at the time of writing it was and still is the accepted one. I have no intention of stealing that reputation, but I also do not want to edit it once more because it is kind of outdated (e.g. link to Codehaus), so I would basically have to rewrite it anyway just so as to update it.
Here is a Maven POM based on
It also contains the plugin repository configuration for the latest Groovy Eclipse version not found on Maven Central.
I am using this setup for my Spock + Geb tests, by the way.
Read more about this topic In the Lombok section of the Groovy-Eclipse wiki.