【发布时间】:2020-05-14 06:10:27
【问题描述】:
${revision} 标签可以在 pom.xml 中使用,如 here 所述。
有这个目录结构:
fix
├── pom.xml
├── parent
│ └── pom.xml
└── example
└── pom.xml
pom.xml 有:
<project>
<groupId>intellij</groupId>
<artifactId>fix</artifactId>
<version>${revision}</version>
<properties>
<project.parent.basedir>parent</project.parent.basedir>
</properties>
<packaging>pom</packaging>
<modules>
<module>parent</module>
<module>example</module>
</modules>
<modelVersion>4.0.0</modelVersion>
</project>
parent/pom.xml 有:
<project>
<groupId>intellij</groupId>
<artifactId>parent</artifactId>
<properties>
<revision>1.0.0</revision>
</properties>
<parent>
<groupId>intellij</groupId>
<artifactId>fix</artifactId>
<version>${revision}</version>
</parent>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
</project>
还有example/pom.xml:
<project>
<groupId>example</groupId>
<artifactId>example</artifactId>
<parent>
<groupId>intellij</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
</project>
IntelliJ 报告:
而终端上的mvn 可以很好地解析它并且可以正常工作。
这会破坏 IntelliJ 中的很多内容。
我用 IntelliJ 2019.2 试过这个
【问题讨论】:
-
您应该将版本属性的属性定义从您的父级移动到项目的根目录(修复工件)。此外,我强烈建议不要使用既是模块又是父级的父级...
标签: maven intellij-idea pom.xml parent-pom