Can I Configure m2eclipse through pom.xml?

。_饼干妹妹 提交于 2019-11-27 14:23:58
Pascal Thivent

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:

  1. Sonatype doesn't maintain it.
  2. It causes them too much troubles.

Second, it states that the m2eclipse way to handle additional project natures and builders is to write project configurators:

(...) we encourage writing configurators to add the natures and builders you want based on what it available in the POM.

See this link for a guide and this project for some existing configurators for checkstyle, findbugs, pmd.

Sean Patrick Floyd

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!