Maven:从子模块中检索主模块版本 [英] Maven: retrieving the main module version from a sub-module

查看:65
本文介绍了Maven:从子模块中检索主模块版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Maven 项目是多模块的,通常版本号不同步.例如,我可以有一个版本为 1.2.3-SNAPSHOT 的主 POM 和一个版本为 3.4.5-SNAPSHOT 的子模块(不保持同步的主要原因是模块经常从一个项目移动到另一个项目,并且必须保留其版本).

My Maven projects are multi-module and in general the version numbers are not synced. For instance, I can have a master POM versioned as 1.2.3-SNAPSHOT and a sub-module versioned 3.4.5-SNAPSHOT (the main reason for not keeping them synced is that often a module is moved from a project to another and it has to keep its version).

现在我想将主项目版本放在包含主(或webapp等)的模块的资源中,这当然是一个子模块.这意味着我需要从子模块访问主 pom 版本.

Now I want to put the main project version in a resource of the module containing the main (or the webapp, etc...), which of course is a sub-module. This means that I need to access the master pom version from a sub-module.

还要注意,我的项目有 3 或 4 个级别;因此主 pom 是子模块的祖父,而不仅仅是父模块.

Also be aware that my projects have got 3 or 4 levels; thus the master pom is the grandfather of the submodule, not just the parent.

尽管对 Maven 有一些经验,包括高级内容,但到目前为止我一直无法解决这个问题.

In spite of having some experience with Maven including advanced stuff, so far I've been unable to solve this problem.

谢谢.

推荐答案

它应该与 ${project.parent.version} 一起使用.

It should work with ${project.parent.version}.

这篇关于Maven:从子模块中检索主模块版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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