在我希望每个模块始终与父模块保持相同版本的 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)用于版本元素时,这是一个一般警告的情况。