Kir*_*ill 6 pom.xml maven maven-profiles
我有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>
Run Code Online (Sandbox Code Playgroud)
我也有一个配置文件,可以通过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>
Run Code Online (Sandbox Code Playgroud)
但是我无法从此配置文件中读取属性。如果我systemPropertyVariables在构建插件配置部分中删除并保留配置文件的pluginManagement配置,则可以正常工作。看来,我需要合并这些属性一起使用时,所以我尝试添加combine.children="append"并combine.self="append"以configuration插件的,但它并没有帮助。
更新:
我已经找到了导致此问题的原因:我没有提到我的父pom包括这个,而父pom.xml有以下几行:
<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>
Run Code Online (Sandbox Code Playgroud)
这些父pom故障安全配置破坏了我的所有配置pom.xml-如果删除父pom参考,则将正确包含故障安全属性。我不能只删除父pom引用,也不能对其进行修改(实际上我可以对其进行分叉和编辑,但这不是一件容易的事),是否可以覆盖这些属性,因为我没有使用它们?
附加的最小可复制项目:https : //send.firefox.com/download/88dfb9f933c9567f/#71ij1jbuEuAYgdwIiZQZRg
我设法通过在不可触摸的(或pariah)父级和当前的之间添加一个额外的pom来做到这一点child,我称之为新的中间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>
Run Code Online (Sandbox Code Playgroud)
这个 pom 成为 的新父 pom child,同时它使用原始pariahpom 作为其父 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
Run Code Online (Sandbox Code Playgroud)
<activation>ps 不要忘记为test配置文件添加某种类型
| 归档时间: |
|
| 查看次数: |
179 次 |
| 最近记录: |