这是关于 Maven POM 的
如果我想让我的父版本也成为我的依赖项的版本,我必须设置一个属性,其值为 ${project.parent.version}。
当我的主 POM 的子级(其中有 ${project.parent.version} 属性,因为它是我不管理的某个项目的父级)重新计算该属性并认为创建的值时,问题就会发生Property 现在是我的 Main 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>
最后是 Child Pom 1.0.0 中的属性 ${dependency.version} 而不是 1.2.3。
这是 Maven 想要的行为吗?我该怎么做才能让它发挥作用?
无法改变的事情:
Maven首先处理继承构建有效的pom,然后处理变量扩展。
换句话说,父 pom 和子 pom 内容将作为每个子 pom 的单个合并文件进行处理。因此,当您的子 pom 正在处理时, ${project.parent.version} 是 1.0.0,而不是 1.2.3。
我找不到引用 pom 的“祖父母”的方法,因此似乎唯一的解决方案是将版本作为静态数字放在parent.version和properties.dependency.version中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)