如何在 Eclipse 中使用 Groovy 开发 Maven 插件

发布于 2024-10-01 10:29:40 字数 446 浏览 1 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暖伴 2024-10-08 10:29:40

如果您计划在 Eclipse 中开发 Groovy 代码,则应该明确安装 Groovy-Eclipse 插件。您可以在这里找到所有详细信息:

http://groovy.codehaus.org/Eclipse+Plugin

您还应该将 Groovy Maven 插件添加到您的 pom.xml 中,如下所示(请参阅 此页面了解详细信息):

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.groovy.maven</groupId>
      <artifactId>gmaven-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>generateStubs</goal>
            <goal>compile</goal>
            <goal>generateTestStubs</goal>
            <goal>testCompile</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

现在通过 右键单击项目 -> 更新您的 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):

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.groovy.maven</groupId>
      <artifactId>gmaven-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>generateStubs</goal>
            <goal>compile</goal>
            <goal>generateTestStubs</goal>
            <goal>testCompile</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Now update your Eclipse project configuration via Right-click on project -> Maven -> Update project configuration. Now you should see that the src/main/groovy folder has been added to the source folders.

酒解孤独 2024-10-08 10:29:40

使用 GMaven 和 eclipse 插件作为 由chkal建议

Use GMaven and the eclipse plugin as suggested by chkal.

烏雲後面有陽光 2024-10-08 10:29:40

除了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文