我有一个多模块(聚合)的Maven项目,还从父pom继承属性。所以在我的父pom.xml中有这个:
<groupId>com.something.project</groupId>
<artifactId>MyProject</artifactId>
<packaging>pom</packaging>
<version>1.0.123</version>
<modules>
<module>ModuleA</module>
<module>ModuleB</module>
<module>ModuleC</module>
</modules>
我希望所有子模块都继承父模块的版本号1.0.123
,但是子模块的pom.xml
仍需要硬编码指定父模块的版本号(ModuleA pom.xml 示例):
<artifactId>ModuleA</artifactId>
<name>Some Amazing Thing</name>
<parent>
<relativePath>../</relativePath>
<artifactId>MyProject</artifactId>
<version>1.0.123</version>
<groupId>com.something.project</groupId>
</parent>
我该如何在父POM中仅放置版本号,并使模块继承它而无需在多个地方进行更新?到目前为止,我已经尝试过${project.version}和${project.parent.version},但Maven似乎非常不高兴。也不能完全删除版本引用。
有人对此有一个好的答案吗?