可以将 parent 版本作为 属性 提供给 children 吗?

Possible to have the parent version as Property to give to the children?

这是关于 Maven POM 的

如果我想让我的 Parent 的版本也成为我的依赖项的版本,我必须设置一个 属性 那个值是 ${project.parent.version}.

当我的主 POM 的 Child(其中有 ${project.parent.version} 属性 时,问题就会发生,因为它是 Parent 一些项目我不管理)重新计算 属性 并认为创建的 属性 的值现在是我的主 POM 的版本。

--SuperParent (not in my Administration) | Version = 1.2.3

----MainPom | Version = 1.0.0 | Property <test>${project.parent.version}</test> -> 1.2.3

------Child Pom | Version 1.0.0 | Property ${test} is now 1.0.0

<project>
<!-- Super Pom -->
 <groupId>groupId</groupId>
    <artifactId>artifactId</artifactId>
    <version>1.2.3</version>
</project>

<project>
<!-- MainPom -->
    <groupId>othergroupId</groupId>
    <artifactId>otherartifactId</artifactId>
    <version>1.0.0</version>
    <parent>
         <groupId>groupId</groupId>
         <artifactId>artifactId</artifactId>
         <version>1.2.3</version>
     </parent>
     <properties>
     <dependency.version>${project.parent.version}</dependency.version>
     </properties>
     <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>dependencyGroupId<groupId>
                <artifactId>dependency</artifactId>
                <version>${dependency.version}</version>
            </dependency>
        </dependencies>
     </dependencyManagement>
</project>
<project>
<!-- ChildPom -->
    <groupId>childGroupId</groupId>
    <artifactId>childArtifactId</artifactId>
    <version>1.0.0</version>
    <parent>
         <groupId>othergroupId</groupId>
         <artifactId>otherartifactId</artifactId>
         <version>1.0.0</version>
     </parent>
        <dependencies>
            <dependency>
                <groupId>dependencyGroupId<groupId>
                <artifactId>dependency</artifactId>
            </dependency>
        </dependencies>
</project>

最后是 属性 ${dependency.version} 在 Child Pom 1.0.0 而不是 1.2.3。 这是 Maven 想要的行为吗?我该怎么做才能让它发挥作用?

无法更改的内容:

Maven先进程继承构建有效pom,再进程变量扩展。

换句话说,父子 pom 内容被处理为每个子 pom 的单个合并文件。因此,当处理您的子 pom 时,${project.parent.version} 是 1.0.0,而不是 1.2.3.

我找不到引用 pom 的 "grandparent" 的方法,所以似乎唯一的解决方案是将版本作为静态数字放在 parent.version 和 properties.dependency.version.