Contact Us 1-800-596-4880

FAQ: How To Handle Parent POM Files

You can declare the MUnit plugin in a parent POM file and every child project under this file can choose to reference this definition.

In order to make a proper use of the MUnit plugin in a parent-child POM relationship, you need to include the MUnit plugin declaration in the <pluginManagement> section of your parent pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.pirate</groupId>
    <artifactId>pirate-pom</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <munit.version>2.0.0</munit.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.mulesoft.munit.tools</groupId>
                    <artifactId>munit-maven-plugin</artifactId>
                    <version>${munit.version}</version>
                    <executions>
                        <execution>
                            <id>test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                      <coverage>
                          <runCoverage>true</runCoverage>
                          <failBuild>false</failBuild>
                          <requiredApplicationCoverage>0</requiredApplicationCoverage>
                          <requiredResourceCoverage>0</requiredResourceCoverage>
                          <requiredFlowCoverage>0</requiredFlowCoverage>
                          <formats>
                              <format>console</format>
                              <format>html</format>
                          </formats>
                      </coverage>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

This pirate-pom project declares the MUnit Maven plugin in its plugin management section, which defines a global configuration that each child under this parent can choose to reference, override or even ignore.