最佳答案
在 maven 多模块项目中,我希望每个模块始终保持与父模块相同的版本,我通常在模块的 pom.xml 中执行以下操作:
<parent>
<groupId>com.groupId</groupId>
<artifactId>parentArtifactId</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<groupId>com.groupId</groupId>
<artifactId>artifactId</artifactId>
<packaging>jar</packaging>
<version>${project.parent.version}</version>
<name>name</name>
由于我开始使用 maven 3.0-alpha-5,因此会得到以下警告。
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.groupid.artifactId:name:jar:1.1-SNAPSHOT
[WARNING] 'version' contains an expression but should be a constant. @ com.groupid.artifactId:name::${project.parent.version}, /Users/whaley/path/to/project/child/pom.xml
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
我很想知道将模块版本与父版本绑定的真正问题是什么(如果有的话) ?或者,当任何表达式(不管它是否是 project.Parent.version)用于 version 元素时,这是一个通用警告。