Eclipse + Subversion (subclipse) + Maven (m2eclipse) 多模块项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4054579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse + Subversion (subclipse) + Maven (m2eclipse) multi-module project
提问by chadmaughan
I have some related legacy projects that are a mess and I would like to mavenize them as a multi-module project shared on subversion (first multi-module project, we've always had them separate). There are a few key parts 1) webservice, 2) various swing clients, 3) model (w/ persistence from hibernate), 4) core JSE tasks.
我有一些相关的遗留项目是一团糟,我想将它们作为在 subversion 上共享的多模块项目进行 mavenize(第一个多模块项目,我们一直将它们分开)。有几个关键部分 1) Web 服务,2) 各种 Swing 客户端,3) 模型(具有来自休眠的持久性),4) 核心 JSE 任务。
I've been messing around for a few days trying to correctly set it up using Eclipse (Helios), Maven (2.2.1), m2eclipse (0.10.0) and Subversion (1.6) for our team. I keep stumping myself or having random errors that force me to backtrack. I'm hoping someone can help me out with some best practices.
几天来,我一直在尝试使用 Eclipse (Helios)、Maven (2.2.1)、m2eclipse (0.10.0) 和 Subversion (1.6) 为我们的团队正确设置它。我不断地难倒自己或出现随机错误,迫使我回溯。我希望有人可以帮助我解决一些最佳实践。
Here are some of the questions:
以下是一些问题:
m2eclipse requires a "flat" eclipse project structure. Does that mean I should create a subversion repository for each module? If I do one repository and try to check in from the parent project I'm having a difficult time setting the svn:ignore property on the nested project target (and other) directories.
m2eclipse 需要一个“扁平”的 eclipse 项目结构。这是否意味着我应该为每个模块创建一个 subversion 存储库?如果我执行一个存储库并尝试从父项目签入,我将很难在嵌套项目目标(和其他)目录上设置 svn:ignore 属性。
If I do a module per repository, I seem to be able to check them in ok. The question then is what is the best way to check out via subclipse? Is there a best order? Parent or child project(s) first? Do I need to checkout the parent project and modify the checkout path of the children project to be nested in the file directory that will allow me to then "clean install" from the parent project?
如果我为每个存储库做一个模块,我似乎可以检查它们。那么问题是通过 subclipse 查看的最佳方式是什么?有最好的顺序吗?首先是父项目还是子项目?我是否需要检出父项目并修改子项目的检出路径以嵌套在文件目录中,然后我才能从父项目“全新安装”?
Or, should I abandon subclipse and m2eclipse and checkout and run my maven goals from the command line.
或者,我应该放弃 subclipse 和 m2eclipse 并结帐并从命令行运行我的 maven 目标。
Or, should I just be using the SCM integration with Maven. Or, maybe just not even try to get a multi-module project setup.
或者,我应该只使用 SCM 与 Maven 的集成。或者,甚至可能只是不尝试进行多模块项目设置。
What do others do? Does anyone have some documentation (I missed) or some links (Google didn't recommend)?
其他人做什么?有没有人有一些文档(我错过了)或一些链接(谷歌不推荐)?
Thanks in advance for your feedback.
提前感谢您的反馈。
采纳答案by Pascal Thivent
m2eclipse requires a "flat" eclipse project structure.
m2eclipse 需要一个“扁平”的 eclipse 项目结构。
Hmm, m2eclipse supports nested projects AFAIK (or at least importing a nested project structure). I don't use Eclipse wizards to create my projects though so maybe I'm not aware of something.
嗯,m2eclipse 支持嵌套项目 AFAIK(或至少导入嵌套项目结构)。我不使用 Eclipse 向导来创建我的项目,所以也许我不知道某些事情。
Does that mean I should create a subversion repository for each module?
这是否意味着我应该为每个模块创建一个 subversion 存储库?
No, no, absolutely not and I wouldn't do that (this will be hard to maintain). However, depending on your projects release cycles, you might have to think about the layout of your repository (single vs multiple trunk/tags/branches), especially if you plan to use the maven release plugin. If some pieces have independent release cycles, then I'd go for several trunk/tags/branches. If you always release them all together (as a single product), then a single trunk/tags/branches should do it. I wrote several answers on the topic that may be of interest:
不,不,绝对不会,我不会那样做(这将很难维护)。但是,根据您的项目发布周期,您可能需要考虑存储库的布局(单个与多个主干/标签/分支),特别是如果您打算使用 Maven 发布插件。如果某些部分有独立的发布周期,那么我会选择几个主干/标签/分支。如果您总是将它们一起发布(作为单个产品),那么应该使用单个主干/标签/分支。我就可能感兴趣的话题写了几个答案:
- Migrating to maven from an unusual svn directory structure?
- Maven parent pom vs modules pom
- How to handle maven versions in a multi module project?
If I do one repository and try to check in from the parent project I'm having a difficult time setting the svn:ignore property on the nested project target (and other) directories.
如果我执行一个存储库并尝试从父项目签入,我将很难在嵌套项目目标(和其他)目录上设置 svn:ignore 属性。
What is the particular problem?
具体问题是什么?
If I do a module per repository, I seem to be able to check them in ok. The question then is what is the best way to check out via subclipse? Is there a best order? Parent or child project(s) first? Do I need to checkout the parent project and modify the checkout path of the children project to be nested in the file directory that will allow me to then "clean install" from the parent project?
如果我为每个存储库做一个模块,我似乎可以检查它们。那么问题是通过 subclipse 查看的最佳方式是什么?有最好的顺序吗?首先是父项目还是子项目?我是否需要检出父项目并修改子项目的检出路径以嵌套在文件目录中,然后我才能从父项目“全新安装”?
Whatever choice you'll make (multiple repositories or not, multiple trunk/tags/branches or not), it should be possible to checkout the whole project structure in one time (using svn:externals
if required). At least, you should try to make it possible (and it is, see the links posted above).
无论您做出何种选择(是否有多个存储库,是否有多个主干/标签/分支),都应该可以一次性检查整个项目结构(svn:externals
如果需要,请使用)。至少,您应该尝试使其成为可能(确实如此,请参阅上面发布的链接)。
But I repeat, I do not recommend using multiple repositories(unless you want independent revision numbers) and nothing forces you to do that.
但是我再说一遍,我不建议使用多个存储库(除非您想要独立的修订号),并且没有什么可以强迫您这样做。
Or, should I abandon subclipse and m2eclipse and checkout and run my maven goals from the command line.
或者,我应该放弃 subclipse 和 m2eclipse 并结帐并从命令行运行我的 maven 目标。
I use Eclipse, m2eclipse, subclipse successfully, all well integrated (at least for the build and "check in" part). But I do the initial import and the initial checkout on the command line and then imported
我成功地使用了 Eclipse、m2eclipse、subclipse,所有这些都很好地集成在一起(至少对于构建和“签入”部分而言)。但是我在命令行上进行了初始导入和初始结帐,然后再导入
Or, should I just being using the SCM integration with Maven.
或者,我应该只是使用 SCM 与 Maven 的集成。
I don't use it, I don't have the need for it.
我不使用它,我不需要它。
Or, maybe just not even try to get a multi-module project setup.
或者,甚至可能只是不尝试进行多模块项目设置。
There is no reason to forbid the use of a multi-modules project setup, multi-modules buildsare one of the key part of Maven.
没有理由禁止使用多模块项目设置,多模块构建是 Maven 的关键部分之一。
What do others do? Does anyone have some documentation (I missed) or some links (Google didn't recommend)?
其他人做什么?有没有人有一些文档(我错过了)或一些链接(谷歌不推荐)?
Have a look at the links I posted :)
看看我发布的链接:)
回答by javamonkey79
It is a bit tricky at first. The way I've typically seen it setup is like so:
一开始有点棘手。我通常看到它设置的方式是这样的:
In subversion:
在颠覆中:
- Parent Project
-- Module A
--- pom.xml (module A)
-- Module B
--- pom.xml (module B)
-- Module c
--- pom.xml (module C)
-- pom.xml (parent project)
Some things to note (you already know):
一些注意事项(你已经知道):
- You have to have the child projects listed as modules in your parent project
- You have to list the parent project in your child pom's (as the parent group, artifact, version)
- When you check out the project from svn, you need to do 'check out as maven project' instead of the standard 'check out' (this one can be a gotcha)
- 您必须将子项目列为父项目中的模块
- 您必须在子 pom 中列出父项目(作为父组、工件、版本)
- 当您从 svn 签出项目时,您需要执行“作为 Maven 项目签出”而不是标准的“签出”(这可能是一个问题)
I hope this helps.
我希望这有帮助。