简体   繁体   English

使用Maven和多个git存储库-减轻痛苦

[英]Working with maven and multiple git repositories - reducing the pain

We recently migrated from SVN, with most code in a single repo, to git, with most projects in their own repos (about 70 of them). 我们最近从SVN迁移到git,其中大多数项目都在其自己的存储库中(其中约有70个),而SVN则在单个存储库中包含大多数代码。 We build about a dozen different apps from this java source. 我们从此java来源构建了大约十二种不同的应用程序。 The apps all run on *nix servers. 所有应用程序都在* nix服务器上运行。 We use maven and nexus to build. 我们使用maven和nexus进行构建。 Many of us are struggling with developing features when that feature touches more than one repo. 当功能涉及多个仓库时,我们中的许多人都在为开发功能而苦苦挣扎。 Here are a few of the challenges: 以下是一些挑战:

  • The developer has to branch each repo separately - we use the same name for all branches for one feature to make tracking less difficult. 开发人员必须分别分支每个存储库-我们对一个功能的所有分支使用相同的名称,以使跟踪难度降低。

  • One must update poms of all repos to point to the updated versions of each repo's artifact. 必须更新所有存储库的poms,以指向每个存储库工件的更新版本。 If multiple people are working on the same branch, there can be a lot of merging others pom changes. 如果多个人在同一个分支上工作,则可能会有很多合并其他pom更改。 When I commit a change to a repo, then the artifact is renamed to "-SNAPSHOT" which means more pom updates. 当我对仓库进行更改时,工件将重命名为“ -SNAPSHOT”,这意味着需要进行更多的pom更新。

  • Changes need to be pushed in the right order or our automated builds will fail, eg: repo A depends on a change to repo B; 需要按正确的顺序推送更改,否则我们的自动构建将失败,例如:repo A取决于对repo B的更改; if repo A is pushed before repo B is built and deployed, then repo A won't build. 如果在构建和部署存储库B之前推送存储库A,则不会构建存储库A。

  • The person reviewing the feature has to look at changes in multiple repos. 审查功能的人员必须查看多个存储库中的更改。

  • When the feature is merged from its branch to, say, master, One has to remember all the repos that were touched. 当功能从其分支合并到主模块时,必须记住所有已触及的存储库。

It looks like switching to a mostly monorepo approach might be best, tho there are some drawbacks there: 看起来最好是改用单一仓库的方法,但是那里有一些缺点:

  • Building the entire codebase with maven takes a looong time. 用maven构建整个代码库需要很长时间。 (Why can't maven be more like make, only building things that have changed or whose dependencies have changed?) (为什么maven不能更像make,仅构建已更改或依赖项已更改的事物?)

  • Each push kicks off a big set of builds and many unit tests rather than just one repo's artifact build and test. 每次推送都会启动大量的构建和许多单元测试,而不仅仅是一个仓库的工件构建和测试。

  • The developers who generally work in one or two repos prefer this new multi-repo world and will resist a change back. 通常在一个或两个存储库中工作的开发人员更喜欢这个新的多存储库环境,并且会拒绝更改。

I've looked into git submodules and sub trees, which don't seem to solve many of our issues (Not sure about Google Repo). 我研究了git子模块和子树,它们似乎无法解决我们的许多问题(不确定Google Repo)。 Some of us use tools like "mu" to help. 我们中有些人使用诸如“ mu”之类的工具来提供帮助。 It would be sweet if there was a toolkit that would help developers maintain versions in poms, and track changes across repos. 如果有一个工具包可以帮助开发人员维护poms中的版本,并跟踪存储库中的更改,那就太好了。

Let me know if you have a set of procedures or tools you use to ease development in this kind of environment. 让我知道您是否有一套用于简化这种环境下的开发的过程或工具。

with most projects in their own repos (about 70 of them).` 大多数项目都在自己的存储库中(其中约70个)。

For me this is where the problems start. 对我来说,这就是问题的开始。 My vote goes for minimising this number significantly. 我的投票赞成大幅减少该数字。

If you really don't want a single repo (1 repo gets my vote) then you could separate the code base into n*change_often repos with 1*change_rarely repo. 如果您真的不想要一个回购协议(1个回购协议得到我的投票),则可以将代码库分为n * change_often回购协议和1 * change_rarely回购协议。 Keeping the n small is important. 保持n小很重要。 This way you would avoid rebuilding the bits that change rarely. 这样,您将避免重建很少更改的位。

Also, even with the a single repo you don't need to reference everything by source and use binaries for base libraries. 同样,即使只有一个存储库,您也无需按源引用所有内容,也无需将二进制文件用于基础库。 When a base library changes the person making the change could also update all the references in one go so that that all projects are up to date. 当基础库发生更改时,进行更改的人员也可以一次性更新所有参考,以便所有项目都是最新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM