使用 Eclipse 自动 Maven 项目更改分辨率
问题是:我们的 3 级 POM 树中有数十个 Maven 子项目(由 m2eclipse 管理),人们每两周不断地添加和删除其中一些子项目。由于并非所有新添加的项目在丢失时都会导致编译时错误,这一事实使问题变得更加复杂。它们最终可能不会被放入 OSGi 容器中,因为人们忘记正确导入它们,并且 Eclipse 由于某种原因无法自动知道它们的存在。
目前,人们必须查看一些邮件列表,每当发生此类事件时,他们必须手动调用根 POM 的导入向导并添加缺少的项目,或者手动删除一些不需要的项目。移动/重命名是删除/添加的组合。
这一切都很容易出错,我们希望以某种方式自动化/简化该过程。
理想情况下,我们希望有以下工作流程: 1)同步 2) 火蚀 3) 一些触发钩子,可以根据最新的 POM 树分析开发人员的工作空间(根 POM 是固定且已知的) 4)某处应该有一些按钮: - 绿色,如果一切正常 - 红色,如果没有 单击它应该会自动删除不需要的项目(并更新 Eclipse 内部)并添加新项目(某种在静默模式下调用导入向导)。
现有的功能可以实现吗?或者我们是否必须以某种方式扩展 m2e?还有其他解决办法吗???
任何帮助将不胜感激!
PS
我们知道,我们遇到的此类问题可能是由于项目结构设计不当造成的。然而,在紧张的发布周期中运行时要解决这个问题并不容易。因此,我们需要一个临时解决方案。
The problem: we have dozens of Maven sub-projects (managed by m2eclipse) in our 3-level POM tree and people keep adding and removing some of them on a bi-weekly basis. The problem is further complicated by a fact that not all newly added projects result in compile-time error when they are missing. The could end up not being dropped into OSGi container since people forget to import them properly and Eclipse for some reason doesn't know about their existence automatically.
Currently, people have to watch some mailing list and whenever there is such an event, they have to go and either manually invoke import wizard for the very root POM and add missing projects or manually remove some of the not needed ones. Moving/renaming is a combination of removing/adding.
That all is very error prone and we would like to automate/simplify the process somehow.
Ideally, we would like to have the following workflow:
1) sync
2) fire Eclipse
3) Some hook to trigger which would analyze developer's workspace against latest POM tree (the very root POM is fixed and known)
4) There should be some button somewhere which would be:
- green, if everything is all-right
- red, if not
Clicking it should automatically remove not needed projects (and update Eclipse internals) and add the new ones (some sort of invoking import wizard in a silent mode).
Is it possible with the existing functionality? Or would we have to somehow extend m2e? Any other solutions???
Any help would be very appreciated!
P.S.
We're aware that this type of problem we have is probably due to badly designed project structure. However, it's not easy to get that fixed while running on tight release cycles. So, we need an interim solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我觉得你正在解决一个错误的问题。我怀疑 m2e 中是否会支持这样的开箱即用的东西 - 除非有一天将每种类型放入其自己的模块中成为最佳实践。一段时间后,项目模块应该稳定下来,并反映可以更改但不频繁更改的架构(仅限主要版本)。如果变化太频繁,那么设计决策就没有考虑足够的考虑。考虑将项目拆分为多个子项目,这些子项目可以签出/克隆并独立工作。
同步更改时,只需检查是否添加/删除了模块 - 如果是,则同步后只需逻辑删除然后导入回现有的 Maven 项目。
This smells to me that you're fixing a wrong problem. I doubt something like this would be supported out-of-the-box in m2e - unless one day it becomes best practice to put each type in it's own module. After some time project modules should stabilize, and reflect architecture which can change but not frequently (major versions only). If it changes too frequently then not enough thought has been put into design decisions. Consider splitting projects into multiple sub-projects which one can checkout/clone and work independently on.
When syncing changes just check if there were modules added/deleted - and if so, after sync just logically remove and then import back existing maven projects.