如何在 Eclipse 中使用 Groovy 开发 Maven 插件
我想在 Groovy 中编写一个 Maven 插件,但在 Eclipse (Galileo) 下。
- 我已经下载并安装了 Groovy-Eclipse 插件,
- 我已经创建了非常简单的 POM 文件(包含在下面)。
- 我创建了一个简单的 Echo mojo 并将其放在“/src/main/groovy/com/acme/maven/plugins/foo”下。
- 我在 Eclipse 中执行了“导入现有 Maven 项目”(使用 M2Eclipse 插件)。
问题是我没有将“src/main/groovy”视为源文件夹,这使得开发变得困难: - 我必须手动创建包目录结构(com/acme/maven/plugins/foo) - 重构可能不会那么容易 - 增量可能行不通。
你们如何在 Eclipse 中使用 Groovy 开发 Maven 插件?
I want to write a Maven plugin in Groovy, but under Eclipse (Galileo).
- I've downloaded and installed Groovy-Eclipse plugin
- I've created my very simple POM file (included below).
- I've created a simple Echo mojo and place it under "/src/main/groovy/com/acme/maven/plugins/foo".
- I performed "Import Existing Maven Project" in Eclipse (using M2Eclipse plugin).
The problem is that I don't see "src/main/groovy" as a source folder, which makes it hard to develop:
- I have to create the package directory structure (com/acme/maven/plugins/foo) manually
- Refactoring probably won't work easily
- Incremental probably won't work.
How do you guys develop your Maven plugins using Groovy in Eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您计划在 Eclipse 中开发 Groovy 代码,则应该明确安装 Groovy-Eclipse 插件。您可以在这里找到所有详细信息:
http://groovy.codehaus.org/Eclipse+Plugin
您还应该将 Groovy Maven 插件添加到您的
pom.xml
中,如下所示(请参阅 此页面了解详细信息):现在通过
右键单击项目 -> 更新您的 Eclipse 项目配置Maven->更新项目配置
。现在您应该看到 src/main/groovy 文件夹已添加到源文件夹中。You should definitvly install the Groovy-Eclipse plugin if you plan to develop Groovy code in Eclipse. You can find all the details here:
http://groovy.codehaus.org/Eclipse+Plugin
You should also add the Groovy Maven Plugin to your
pom.xml
like this (see this page for details):Now update your Eclipse project configuration via
Right-click on project -> Maven -> Update project configuration
. Now you should see that thesrc/main/groovy
folder has been added to the source folders.使用 GMaven 和 eclipse 插件作为 由chkal建议。
Use GMaven and the eclipse plugin as suggested by chkal.
除了 GMaven 和 Groovy-Eclipse 之外,还有对 Groovy-Eclipse 的 m2eclipse 支持,应单独安装。转至 Groovy-Eclipse 快照更新站点:
http://dist。 codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/
并从那里安装该功能。此功能将确保您的 groovy/maven 项目在导入时正确设置。
In addition to GMaven, and Groovy-Eclipse, there is m2eclipse support for Groovy-Eclipse that should be installed separately. Go to the Groovy-Eclipse snapshot update site:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/
And install the feature from there. This feature will ensure that your groovy/maven projects are set up correctly when they are imported.