日食 +梅文 + git +多模块项目 = 不快乐
我们有一个使用 Eclipse 和 Maven 的多模块项目。过去我可以让它工作的唯一方法是对项目使用平面布局,其中父模块是其他模块的对等体。这与 m2eclipse 和 Subversion 配合得很好。
现在我们想转移到 Git 和 GitHub。我想将整个项目以及所有模块作为 GitHub 上的单个项目公开。问题是 EGit(Eclipse/Git 插件)想要一次管理一个项目,而不是一组项目,因此如果您有平面布局,则无法做到这一点。
正确的答案是使用标准的 Maven 分层布局,并将父模块和所有模块作为一个单元进行管理。但 Eclipse 不喜欢这样,无论怎样摆弄都无法让 Eclipse 接受嵌套项目。 m2Eclipse 不支持层次结构: https://issues.sonatype.org/browse/MNGECLIPSE-2291
那么该怎么办你做?是否从命令行使用 Git 并放弃在 Eclipse 中查看哪些文件已更改的功能?或者放弃Eclipse?
We've got a multi-module project using Eclipse and Maven. The only way I could get it to work in the past was to use a flat layout for the projects, where the parent module was a peer to the other modules. This worked fine with m2eclipse and Subversion.
Now we'd like to move to Git and GitHub. I'd like to expose the entire project, along with all the modules, as a single project on GitHub. The problem is that EGit, the Eclipse/Git plugin, wants to manage projects one at a time, not groups of projects, and so if you've got a flat layout, you can't do it.
The right answer is to use a standard Maven hierarchical layout and manage the parent and all the modules as a unit. But Eclipse doesn't like that, and no amount of fiddling will get Eclipse to accept nested projects. m2Eclipse does not support hierarchies: https://issues.sonatype.org/browse/MNGECLIPSE-2291
So what do you do? Do Git from the command line and abandon the ability to see what files have changed in Eclipse? Or abandon Eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
作为单个 git 存储库的标准 Maven 多模块结构在带有 M2e 的 Eclipse Indigo 以及在该环境中显示的 git 插件中对我来说工作得非常好。你不能要求 Eclipse 为你获取数据,但是一旦你已经从命令行拉取了,你使用团队/共享,说“Git!”一切都很好。
我想我明白了来源:层次结构是工作区内部项目的问题,而不是您导入的“现有项目”的问题。
这是一个典型的工作流程:
工作正常。嵌套不会对日食产生丝毫干扰。不知道bz指的是什么问题。
在使用 m2e 之前,我使用过 maven-eclipse-plugin。它在这些情况下也有效,因为它不会为
pom
聚合项目生成 .project/.classpath,因此从不要求 Eclipse 实际嵌套任何内容。我并不孤单——请参阅 cxf.apache.org 上的开发人员设置说明,获取您可以亲自尝试的开源示例。
A standard Maven multi-module structure as a single git repo works perfectly fine for me in Eclipse Indigo with M2e and the git plugin that shows up in that environment. You can't ask Eclipse to do your fetching for you, but once you've pulled from command line, you use Team/Share, say 'Git!' and all is well.
I think I see what's the source: hierarchy is a problem for projects inside the workspace, not 'existing projects' that you import.
Here's a typical workflow:
it works fine. The nesting does not disturb eclipse one bit. I don't know what problem that bz is pointing at.
Before I used m2e I used the maven-eclipse-plugin. And it also worked in these cases, because it does not generate a .project/.classpath for
<packaging>pom</packaging>
aggregating projects, so Eclipse is never called upon to actually nest anything.I'm not alone -- see the developer setup instructions as cxf.apache.org for an open source example that you can try for yourself.
您是否可能使用旧版本的工具?
我有一个 Maven 多模块项目,使用 Eclipse 3.7 (Indigo)、M2Eclipse (1.0) 和 EGit (1.0) 进行处理。
在文件系统上,多模块项目有一个父目录。
在 Eclipse 中,每个模块都有单独的项目。
M2Eclipse 完美地完成了依赖管理。
顶层有一个 git 存储库(.git 目录),EGit 工作得很好。
Is it possible that you are working with old versions of the tool?
I have a Maven multi-module project that I work with using Eclipse 3.7 (Indigo), M2Eclipse (1.0) and EGit (1.0).
On the file system the multi-module project has a single parent directory.
In Eclipse I have separate projects for each module.
M2Eclipse does the dependency management perfectly.
There is single git repository (.git directory) at the top-level and EGit works perfectly.
您可以将模块放入具有分层布局的 Git 中。并通过 Maven 构建这些模块。如果这些模块是 Eclipse 识别的项目(无论是 java、c++ 或 php 项目),则可以将它们作为工作区中的平面布局导入到工作区中。
You can put your modules in Git with hierarchical layout. And build those modules by Maven. If those modules are projects(whatever java, c++ or php project) recognized by Eclipse, they can be imported into workspace as flat layout in workspace.
对于 Maven 项目,可以通过 Maven 导入向导(可从 Git 访问)实现一次多个导入。
如果您不知道要导入什么类型的项目,您可以使用新的 Easymport,通过从各种文件中推导配置,“尽可能”地导入项目。请参阅 https://github.com/ jbosstools/jbosstools-playground#easymport-easy-and-smart-openimport-of-a-project
获得所有这些项目后,您可以使用 Nestor 插件,该插件将以嵌套/分层布局显示项目,更正确地映射您的 Maven 项目: https://github.com/jbosstools/jbosstools-playground#nestor-view-nested-projects
For Maven projects, multiple imports at once can be achieved via the Maven import wizard (that is accessible from Git).
In case you don't know what kind of projects you're about to import, you can use the new Easymport that will import project "as best", by deducing configurations from various files. See https://github.com/jbosstools/jbosstools-playground#easymport-easy-and-smart-openimport-of-a-project
Once you get all those projects, you can use the Nestor plugin, which will show project in a nested/hierarchical layout, mapping more correctly your Maven project: https://github.com/jbosstools/jbosstools-playground#nestor-view-nested-projects