覆盖配置文件中的插件配置



我有多个配置文件的maven项目。在一个配置文件中,我有插件配置(jacoco-maven-plugin强制执行测试覆盖率(:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<configuration>
<rules>
<rule>
<limits>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
<!-- many other limits here -->
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>

但是在Windows上,我想跳过一些测试并更改覆盖范围限制,我正在尝试这样做:

<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.children="append">
<excludes>
<exlude>com.example.SomeTest</exclude>
</exclude>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<configuration>
<rules>
<rule>
<limits>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.49</minimum>
</limit>
</limits>
</rule>
</rules>
<excludes>
<exlude>com.example.SomeTest</exclude>
</exclude>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

这个测试com.exaple.SomeTest现在不在 Windows 上执行,也没有从覆盖率报告中排除,但jacoco-maven-plugin没有改变:它不会影响插件配置,我也尝试使用<limit combine.children="override"><limit combine.children="append">而不是<limit>.

如何在配置文件的插件配置中正确覆盖只有一个限制(COVEREDRATIO(?

目前,您在每次执行中都有配置,这意味着如果您检查有效的 pom,则会保留每个执行配置文件的这些配置。

我相信您需要的是拥有要在插件级别覆盖的配置。

最新更新