我想在构建后解析所有修订标签,所以我使用展平。我有一个这样的多模块项目:
A (root)
|_B (parent = A, dependencyManagement with version = ${revision}
|_C (parent = B, dependencies declared in dependencyManagement without specifying the version)
Run Code Online (Sandbox Code Playgroud)
问题是在 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>
Run Code Online (Sandbox Code Playgroud)
我尝试在其中添加此部分<configuration>:
<pomElements>
<dependencyManagement>expand</dependencyManagement>
<dependencies>expand</dependencies>
</pomElements>
Run Code Online (Sandbox Code Playgroud)
这部分解决了问题,因为它解决了所有版本,但是 pom 变得太冗长,因为它扩展了父级的所有依赖项。所以结果是 C …