可以通过pom.xml配置m2eclipse吗? [英] Can I Configure m2eclipse through pom.xml?

查看:127
本文介绍了可以通过pom.xml配置m2eclipse吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用maven-eclipse插件,使用 mvn eclipse:eclipse ,您可以指定eclipse 项目性质建立者将自动添加到eclipse项目。



早期版本的 m2eclipse 使用maven-eclipse-plugin的配置块,还可以使用相同的机制激活自然和构建器。这似乎不再是这样的情况,因为a)我在m2eclipse源中找不到任何对 maven-eclipse-plugin 的引用,并且b)它不起作用: - )



所以这是我的问题:有没有办法从pom.xml配置由m2eclipse生成的eclipse项目?具体来说,项目构建者和性质,但我也对其他选项感兴趣。

解决方案

我现在已经实现了一个maven插件我称之为maven-eclipseconf-plugin。
不幸的是,它是客户端的专有工作,所以我无法分享。但是让我描述我所做的:



对生命周期进行验证,我检查是否存在eclipse .project 文件。如果它在那里,我检查它是否存在我想要自动添加的构建器和性质(并且可以通过使用具有可配置名称的maven属性或停止文件来停用此行为)。您还可以定义将要编写的配置文件(如.pmd,与这个我的另一个问题我们的)。配置文件的内容可以内联指定,它可以来自外部文件,也可以来自URL。我还试图在配置文件中引入变量替换,其中特殊的占位符将被multi-moduke项目的根文件夹替换,但我不得不放弃这种方法



无论如何,这个插件给了我几乎所有的功能href =http://maven.apache.org/plugins/maven-eclipse-plugin =nofollow noreferrer> maven-eclipse-plugin 我曾经使用过(当然还有很多)我很高兴。也许当这个合同完成后,我将在开放源代码中再次建立类似的东西。


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.

解决方案

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.

这篇关于可以通过pom.xml配置m2eclipse吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆