18

I'm using enforcer plugin in a multi-node project in the root pom, but I have one testing module, that I don't really care to run the plugin there since it won't create any jar and is only for testing purposes. Is there any way to skip one of the modules in the plugin config?.

Checking the documentation I cannot find anything. Only how to ban some specific dependencies. https://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html

The solution to put the plugin in each sub-module is possible but it's dangerous, since if I create a new sub-module I might forget to add it there.

Here my plugin config.

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.0.0-M3</version>
          <executions>
            <execution>
              <id>enforce-maven-version-and-dependencies</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>3.3.9</version>
                  </requireMavenVersion>
                  <bannedDependencies>
                    <searchTransitive>true</searchTransitive>
                  </bannedDependencies>
                  <dependencyConvergence></dependencyConvergence>
                </rules>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <fail>true</fail>
          </configuration>
        </plugin>
Jaap
  • 641
  • 12
  • 19
paul
  • 12,873
  • 23
  • 91
  • 153

2 Answers2

33

In the POM of the module, set enforcer.skip to true:

<properties>
  <enforcer.skip>true</enforcer.skip>
</properties>
J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
32

Alternatively when building the specific module from command line you can use the following command option.

mvn -Denforcer.skip=true clean install
mvn -Denforcer.skip=true clean package
mtotowamkwe
  • 2,407
  • 2
  • 12
  • 19