如何同时创建 Maven 项目并对其进行分支?
我的公司做了很多看起来非常相似的项目。是时候采用 Maven 原型了,对吧?我想是的。
为了加快这个过程,我不希望每个项目的开发人员都必须手动设置源代码控制(我们使用 Mercurial)。相反,当项目是从 Maven 原型创建时,它应该已经附加到版本控制存储库,并且 Maven 仅为该项目创建一个分支。
到目前为止,我的尝试有一个原型,其源 pom 中包含所需的 SCM 信息,因此该项目是使用版本控制创建的。但是,由于磁盘上没有 .hg 目录,Mercurial 不相信该项目处于源代码控制之下。我认为我唯一的选择是使用 scm:bootstrap 做一些事情,但我不确定:我只使用 Maven 两天。
顺便说一句,我们正在使用 Eclipse 和 m2eclipse 插件,所以如果有一种仅 Eclipse 的方法可以做到这一点,那对我来说没问题。
My company does a lot of projects that look very similar. Time for a Maven archetype, right? I think so.
To speed up the process, I don't want the developer of each project to have to manually set up source control (we use Mercurial). Instead, when the the project is created from a Maven archetype, it should already be attached to a version control repository, and Maven creates a branch just for that project.
My attempt so far has an archetype whose source pom has the desired SCM info in it, so the project is created with version control. However, since there's no .hg directory on disk, Mercurial doesn't believe the project's under source control. I think my only option is doing something with scm:bootstrap, but I'm not sure: I've only been working with Maven for two days.
BTW, we're using Eclipse and the m2eclipse plugin, so if there's an Eclipse-only way of doing this, it's fine with me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有广泛使用 Mercurial,但据我所知,如果每个项目都在自己的存储库中,它的效果最好。
我必须习惯这种与 Subversion 工作方式的默认差异,在 Subversion 工作方式中,在一个存储库中拥有多个项目是很自然的。
分支适用于存储库中的所有文件,如果该存储库包含多个项目,那么它们都会在分支以及所有后续克隆上进行。
如果您正在创建许多类似的项目,当您可能一次只处理其中一个项目时,您真的想将所有这些项目都放在一个存储库中吗?
每次标记或分支一个项目时,您都会将该标记应用于存储库中的所有项目。
请参阅这篇文章了解开发人员的想法关于如何将 Maven 与 Mercurial 一起使用。
请注意,创建项目后,无论是否通过原型,第一步都是通过发出命令
hg init
来“手动”创建存储库。I haven't used mercurial extensively, but from what I've seen it works best if each project is in its own repository.
I had to get used to this difference from the default way that subversion works, where it is natural to have multiple projects in a single repository.
The branch applies to all files in the repository, and if that repository contains multiple projects, then they're all carried through on the branch, and all subsequent clones.
If you're creating a lot of similar projects, do you really want to carry all of them around in your one single repository, when you probably only working on one of them at a time?
And every time that you tag or branch one project you'll have that tag applied to all projects in the repository.
See this article for a developers thought on how to use maven with mercurial.
Note that after creating the project, whether via an archetype or not, the first step is to create the repository 'manually' by issuing the command
hg init
.