【发布时间】:2019-01-25 01:53:33
【问题描述】:
我有 maven 故障安全插件的构建配置,其中包括 systemPropertyVariables:
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<buildDirectory>${project.build.directory}</buildDirectory>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
我还有一个配置文件,可以通过pluginManagement 将一些属性附加到同一个插件:
<profile>
<id>test</id>
<activation>
<property>
<name>test.host</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<TEST_HOST>test.host</TEST_HOST>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
但我无法从此配置文件中读取属性。如果我在构建插件配置部分中删除 systemPropertyVariables 并保留在配置文件的 pluginManagement 配置中,它工作正常。看来我需要在一起使用时合并这些属性,所以我尝试将combine.children="append"和combine.self="append"添加到插件的configuration,但没有帮助。
更新:
我找到了这个问题的原因:我没有提到我有父 pom,包括来自这个的,而父 pom.xml 有这些行:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.0.0-M3</version>
<configuration combine.children="append">
<systemProperties>
<!-- some properties that I don't use -->
</systemProperties>
</configuration>
</plugin>
这些父 pom 故障安全配置正在破坏我的 pom.xml 中的所有配置 - 如果我删除父 pom 引用,故障安全属性将被正确包含。我不能只删除父 pom 引用并且不能修改它(实际上我可以分叉和编辑它,但这不是一件容易的事),是否可以覆盖这些属性,因为我不使用它们?
附加最小可重现项目:https://send.firefox.com/download/88dfb9f933c9567f/#71ij1jbuEuAYgdwIiZQZRg
【问题讨论】:
-
你能提供一个可下载的例子吗?
-
你试过
mvn help:effective-pom -Ptest这样的做法吗?在这里快速尝试,使用上面的 XML,在<systemPropertyVariables>下显示<buildDirectory>和<TEST_HOST> -
@MarinosAn @df778899 很抱歉回复太长,没有时间更深入地检查,我更新了有关
pom.xml的更多详细信息
标签: maven pom.xml maven-profiles