Maven 多模块项目持续集成的标准实践
我查了一下,找不到一个好的答案:
我们有一个多模块 Maven 项目,我们想要持续集成它。我们想到了两种处理此问题的策略:
- 让我们的持续集成服务器(在本例中为 TeamCity,但我之前使用过其他服务器,它们似乎也有相同的问题)指向聚合器 POM 文件,然后立即构建所有内容
- 我们的持续集成服务器是否指向每个单独的模块?
是否有一个标准的、首选的实践?我查过 Stack Overflow、Google、持续集成书籍,但没有找到任何东西,但也许我错过了。
I checked around, and couldn't find a good answer to this:
We have a multi-module Maven project which we want to continuously integrate. We thought of two strategies for handling this:
- Have our continuous integration server (TeamCity, in this case, but I've used others before and they seem to have the same issue) point to the aggregator POM file, and just build everything at once
- Have our continuous integration server point at each individual module
Is there a standard, preferred practice for this? I've checked Stack Overflow, Google, the Continuous Integration book, and did not find anything, but maybe I missed it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至少,与 Hudson 进行标准练习是您的第一选择。一方面,在 Maven 中,如果所有项目没有一起在 Reactor 中,您的构建可能无法很好地工作。另一方面,尝试将它们分开构建将使您陷入快照管理困境。如果中间的一个发生变化,并且您尝试构建它,maven 将会以快照的形式寻找其依赖项。它得到什么将取决于其他项目构建的顺序,以及您是否发布快照。
如果你有这么多项目,或者这样不相关的项目,构建它们都是一个问题,那么我建议你需要考虑分解。使父项目成为一个单独的、已发布的项目,为每个项目(或每个子组)提供一个主干/标签/分支结构,并使它们依赖于版本,而不是快照。
Standard practice with Hudson, at least, is your first option. For one thing, in maven, your build may not work very well if all the projects are not in the reactor together. For another, trying to make them separate builds is going to put you in snapshot-management heck. If one in the middle changes, and you try to build just it, maven will go looking for its dependencies as snapshots. What it gets will depend on the order in which other projects build, and whether you publish snapshots.
If you have so many projects, or such unrelated projects, that building them all is a problem, then I suggest that you need to consider dis-aggregation. Make the parent a separate, released, project, give each of them (or each subgroup of them) a Trunk/Tags/Branches structure, and make them depend on releases, not snapshots.
理想的做法是运行反应器构建来仅构建包含更改的模块(使用
--projects
选项)和依赖于它们的模块(使用--also-make-dependents
选项)。但 TC 目前不支持等效功能(检查 TC 5 EA:Maven 2 依赖项触发器不工作...),因此,好的做法是运行完整的反应堆构建(您不希望单个模块在没有警告的情况下破坏依赖于它的模块,您希望保持同步的连贯快照集)。
The ideal practice would be to run a reactor build to build only the modules containing changes (with the
--projects
option) and on the modules that depend on them (with the--also-make-dependents
option).But TC doesn't support an equivalent feature for now (check TC 5 EA: Maven 2 dependency triggers not working...) and the good practice is thus to run a full reactor build (you do not want an invidual module to break modules that depends on it without being warned, you want to keep coherent sets of SNAPSHOTS in sync).