2

I have maven project with multiple profiles. In one profile I have plugin configuration (jacoco-maven-plugin to enforce test coverage):

<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>

But on Windows I want to skip some test and change coverage limits, I'm trying to do it like this:

<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>

This test com.exaple.SomeTest is not executed on windows now and excluded from coverage reports, but jacoco-maven-plugin didn't change: it doesn't affect plugin configuration, I also tried to use <limit combine.children="override"> and <limit combine.children="append"> instead of <limit>.

How to correctly override only one limit (COVEREDRATIO) in plugin configuration for profile?

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
Kirill
  • 7,580
  • 6
  • 44
  • 95

1 Answers1

0

Currently you have configuration within each execution which means that if you check the effective pom, these configurations for each execution profile are persisted.

What I believe you need is to have the configuration you want to override at the plugin level.

Dio
  • 684
  • 2
  • 9
  • 18