Maven 覆盖配置文件中的插件配置
我有多个配置文件的maven项目。在一个配置文件中,我有插件配置(Maven 覆盖配置文件中的插件配置,maven,pom.xml,maven-plugin,jacoco,jacoco-maven-plugin,Maven,Pom.xml,Maven Plugin,Jacoco,Jacoco Maven Plugin,我有多个配置文件的maven项目。在一个配置文件中,我有插件配置(jacocomaven-plugin以强制测试覆盖率): org.jacoco jacocomaven插件 0.8.0 分支机构 覆盖层 0.50 但在Windows上,我想跳过一些测试并更改覆盖范围限制,我尝试这样做: <profile> <id>windows</id> <activation> <os> <family>w
jacocomaven-plugin
以强制测试覆盖率):
org.jacoco
jacocomaven插件
0.8.0
分支机构
覆盖层
0.50
但在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>
窗户
窗户
maven surefire插件
com.example.SomeTest
org.jacoco
jacocomaven插件
0.8.0
分支机构
覆盖层
0.49
com.example.SomeTest
这个测试com.example.SomeTest
现在没有在windows上执行,也没有从覆盖率报告中排除,但是jacoco maven plugin
没有改变:它不影响插件配置,我也尝试使用
和
而不是
如何在配置文件的插件配置中仅正确覆盖一个限制(
COVEREDRATIO
)?当前,您在每次执行中都有配置,这意味着如果您检查有效的pom,则每个执行配置文件的这些配置都会被保留
我认为您需要的是在插件级别上覆盖您想要覆盖的配置
<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>