Maven2继承 [英] Maven2 inheritance

查看:82
本文介绍了Maven2继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个父pom,并且想将其继承到几个项目中.我通常通过在项目<parent> ... </parent>的顶部添加来完成此操作.我对这种方法不满意的是,如果我的父级发生了某些变化,我必须编辑该父级继承的所有项目以修改版本号.有没有更好的方法?我希望这是可以理解的.

If I have a parent pom and want to inherit this to several projects. I usually do this by adding in top of the project <parent> ... </parent>. What I don't like about this approach is that if something changes in my parent I have to edit all project which are inherited by that parent to modify the version number. Is there a better approach? I hope it is understandable what I'm trying to explain.

先谢谢了.

推荐答案

我不喜欢这种方法 是如果我的事情发生变化 父母,我必须编辑所有项目 由该父母继承的 修改版本号.有没有 更好的方法?

What i don't like about this approach is that if something changes in my parent i have to edit all project which are inherited by that parent to modify the version number. Is there a better approach?

是的!看看 Maven版本插件,特别是:

versions:update-child-modules 更新了 项目的子模块,因此 版本与的版本匹配 当前的项目.
例如,如果您 有一个聚合器pom 它的项目的父级 聚合以及孩子和父母 版本不同步,这个魔力 可以帮助修复孩子的版本 模块.
(请注意,您可能需要调用 使用-N选项进行Maven操作 如果您的项目是 坏得很厉害,以至于无法建立 因为版本不匹配).

versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project.
For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules.
(Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).


编辑:当然,使用Maven3,您现在可以拥有<版本> -less<子模块中的parent>元素:


Of course, using Maven3 you can now have < version >-less < parent > elements in sub modules:

在多模块或多pom项目中工作的开发人员不必在Maven 3的每个子模块中指定父版本.相反,您可以添加无版本的父元素.

Developers working in multi-module or multi-pom projects won't have to specify the parent version in every sub-module in Maven 3. Instead, you can add version-less parent elements.

参考

这篇关于Maven2继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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