【发布时间】:2020-03-30 16:26:16
【问题描述】:
我想在构建之后解析所有的修订标签,所以我正在使用 flatten。我有一个这样的多模块项目:
A (root)
|_B (parent = A, dependencyManagement with version = ${revision}
|_C (parent = B, dependencies declared in dependencyManagement without specifying the version)
问题是在 B 的扁平 pom 中,${revision} 没有解决。此外,在 C 的扁平化 pom 中,该版本仍然缺失,而我希望找到在 B 中的dependencyManagement 中声明的版本。
这是我配置扁平化的方式:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我尝试在<configuration> 中添加此部分:
<pomElements>
<dependencyManagement>expand</dependencyManagement>
<dependencies>expand</dependencies>
</pomElements>
这部分解决了问题,因为它解决了所有版本,但是 pom 变得过于冗长,因为它扩展了父级的所有依赖项。所以结果是C的扁平化pom显式包含了B e A中声明的所有依赖,以及B的dependencyManagement。
有没有办法只解决版本而不扩展子 pom 中的所有依赖项?
【问题讨论】:
标签: java maven version maven-plugin flatten