我可以通过pom.xml配置m2eclipse吗?
通过 maven-eclipse-plugin,使用 mvn eclipse: eclipse
,您可以指定 eclipse 项目性质和构建器它将自动添加到 eclipse 项目中。
早期版本的 m2eclipse 使用 maven-eclipse-plugin 的配置块,还允许您使用以下命令激活性质和构建器相同的机制。这似乎不再是这种情况,因为 a) 我在 m2eclipse 源代码中找不到任何对 maven-eclipse-plugin
的引用,b) 它不起作用:-)
所以这是我的问题:有什么方法可以配置 m2eclipse 从 pom.xml 生成的 eclipse 项目吗?具体来说:项目建设者和性质,但我也对其他选择感兴趣。
With the maven-eclipse-plugin, using mvn eclipse:eclipse
, you can specifiy eclipse project natures and builders that will automatically be added to the eclipse project.
Earlier versions of m2eclipse used the configuration block of the maven-eclipse-plugin and also let you activate natures and builders using the same mechanisms. This seems to no longer be the case because a) I can't find any reference to maven-eclipse-plugin
in the m2eclipse sources and b) it just doesn't work :-)
So this is my question: is there any way to configure the eclipse project generated by m2eclipse from the pom.xml? Specifically: project builders and natures, but I'd be interested in other options as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下 线程总结了几乎所有内容。首先,它解释了 m2eclipse 不再支持 Maven Eclipse 插件中的任何内容,因为:
其次,它指出 m2eclipse 处理其他项目性质和构建器的方法是编写项目配置器:
请参阅此链接获取指南和此项目用于 checkstyle、findbugs、pmd 的一些现有配置器。
The following thread summarizes almost everything. First, it explains that m2eclipse doesn't and won't support anything from the Maven Eclipse Plugin anymore because:
Second, it states that the m2eclipse way to handle additional project natures and builders is to write project configurators:
See this link for a guide and this project for some existing configurators for checkstyle, findbugs, pmd.
我现在已经将其实现为一个 Maven 插件,我称之为 maven-eclipseconf-plugin。
不幸的是,这是客户的专有工作,所以我无法分享它。但让我描述一下我所做的事情:
与生命周期验证相关,我检查 eclipse
.project
文件是否存在。如果它在那里,我会检查它是否存在我想要自动添加的构建器和性质(您可以通过使用 Maven 属性或具有可配置名称的停止文件来停用此行为)。您还可以定义将要写入的配置文件(例如 .pmd,它与 我的另一个问题)。配置文件的内容可以内联指定,它可以来自外部文件,也可以来自 URL。我还尝试在配置文件中引入变量替换,其中特殊占位符将替换为多 moduke-project 的根文件夹,但是 我不得不放弃这种方法。无论如何,该插件为我提供了 maven-eclipse-plugin 我曾经使用过(当然还有更多)并且我对此很满意。也许当这份合同完成后,我会在开源中再次构建类似的东西。
I have now implemented this as a maven plugin I call maven-eclipseconf-plugin.
Unfortunately it's proprietary work for a client, so I can't share it. But let me describe what I do:
Tied to the lifecycle verify, I check for the existence of an eclipse
.project
file. If it's there, I check it for the presence of the builders and natures I want to automatically add (and you can deactivate this behavior by using a maven property or a stop file with a configurable name). You can also define configuration files that will be written (like .pmd, which is related to this other question of mine). The contents of the Configuration files can be specified inline, it can come from an external file, or from a URL. I also tried to introduce variable substitution in the config files where a special placeholder would be replaced with a multi-moduke-project's root folder, but I had to give up on that approach.Anyway, the plugin gives me pretty much all the functionality of the maven-eclipse-plugin I ever used (of course there is a lot more though) and I'm happy with that. Perhaps I will build something similar once more in open source when this contract is finished.
项目配置器是建议的方法。但 m2e-extensions 的最新版本是 2010 年初,针对 m2eclipse 0.10.x 开发的。有一个名为 m2e-code-quality 的后续项目,它更新且活跃,是针对 m2eclipse 0.12.x 开发的。
但目前 m2e-extensions 和 m2e-code-quality 都不支持 FindBugs。头文件还有一些其他限制、排除和修改的 JAR。
我已成功使用 AntRun 的通用方法、Ant 和 XMLTask 自动从 pom.xml 为 Eclipse 插件添加项目性质、构建器和配置文件。
Project configurators are the proposed approach. But the latest version of m2e-extensions is from early 2010 and developed against m2eclipse 0.10.x. There is a successor project called m2e-code-quality which is more recent and active and developed against m2eclipse 0.12.x.
But neither m2e-extensions nor m2e-code-quality do support FindBugs at the moment. And there are some other limitations with header files, exclusions and modified JARs.
I have successfully used a universal approach with AntRun, Ant and XMLTask to automatically add project natures, builders and configuration files for Eclipse plugins from pom.xml.