我有maven failsafe插件的构建配置,其中包括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>
但我无法读取此配置文件中的属性。如果我在build plugin configuration部分删除systemPropertyVariables
,并保留profile的pluginManagement配置,则可以正常工作。在一起使用时,我似乎需要合并这些属性,所以我尝试将combine.children="append"
和combine.self="append"
添加到插件的configuration
中,但无济于事。
更新:我已经找到了这个问题的原因:我没有提到我有parent pom,包括这个,parent 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
发布于 2019-06-26 16:10:26
我设法做到了这一点,在不可触及(或pariah
)的父级和当前的child
之间添加了一个额外的pom,我称之为这个新的中间pom midboy
=)
因此,midboy
与pariah
只有以下区别;
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.0.0-M3</version>
<inherited>false</inherited>
</plugin>
并且该pom成为child
的新的父pom,同时它使用原始的pariah
pom作为其父。
child
-继承-> midboy
-继承-> pariah
使用inherited:false
,我基本上切断了传递到child
中的故障安全插件,并破坏了它的基于配置文件的配置,以及它自己的本地故障安全插件和配置。这可以完美地工作!
这次不能跳过测试!
Running com.test.so51905256.PropITCase
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 s - in com.test.so51905256.PropITCase
附注:不要忘记为test
配置文件添加某种类型的<activation>
https://stackoverflow.com/questions/51905256
复制相似问题