Maven:多模块项目和版本控制 [英] Maven : Multimodule projects and versioning

查看:919
本文介绍了Maven:多模块项目和版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Maven进行软件版本控制和多模块项目的最佳实践是什么?

What are the best practices for software versioning and multimodules projects with Maven?

我的意思是,当我使用Maven创建多模块项目时,最好的版本控制方法是什么?要对所有模块使用单个版本(在顶级项目中定义)?为每个模块使用版本(在每个模块的POM中定义)?我还缺少另一种方法吗?每种方法的优缺点是什么?

I mean, when I create a multimodules project with Maven, what is the best approach for the versioning? To use a single version for all the modules (defined in the top project)? To use a version for each module (defined in the POM of each module)? Is there another approach that I'm missing? What are the pros and cons of each approach?

通常,不同的模块是否一起发布(可能共享相同的版本号)?

In general, are the different modules released together (possibly sharing the same version number)?

谢谢

推荐答案

老实说,这取决于您要执行的操作.创建多模块项目的原因多种多样,其中之一就是您只需要部署已更改的内容,而不是所有模块.

Honestly it depends on what you would like to do. Multimodule projects are created for multiple reasons, one of them being you only need to deploy what has changed instead of all modules.

这样想:如果您有一个非多模块项目,而只需要在服务层中更改一行,就必须重新构建整个项目并再次部署所有代码...甚至尽管只有您的服务层会发生变化.

Think about it this way: if you had a non-multi-module project and you only had to change one line in the services layer, you have to rebuild the entire project and deploy all of the code again...even though only your services layer will change.

对于多模块项目,您可以重新生成项目并仅部署已更改的内容...您的服务.这样可以降低风险,并且可以确保只更改了服务模块.

With multi-module projects, you can regenerate your project and deploy only what changed...your services. This reduces risk and you're assured that only your services module changed.

使用未在此处列出的多模块项目也有很多好处,但是不保持模块的版本号同步当然会有很大的好处.

You also have a multitude of benefits to using multi-module projects that I'm not listing here but there is certainly a huge benefit to NOT keeping your version numbers of your modules in sync.

在构建项目时,请考虑将其部署到将所有兼容jar在一起存储的存储库中(每个构建都使用最父pom版本号创建一个新文件夹).这样,您就不需要保留有关兼容的jar的文档了……它们都只是与内部版本号一起部署了.

When you build your project, consider deploying it to a repository that will hold all compatible jars together for builds (each build creates a new folder with the parent-most pom version number). That way, you don't need to keep documentation about which jars are compatible...they're all just deployed together with a build number.

这篇关于Maven:多模块项目和版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆