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>
The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules.
This rule checks the dependencies and fails if any of the matching excludes are found. The following parameters are supported by this rule: searchTransitive - if transitive dependencies should be checked.
Maven Enforcer has two goals: enforcer:enforce and enforcer:display-info. The enforce goal runs during a project build to execute rules specified in the configuration, while the display-info goal shows current information about the built-in rules that are present in the project's pom.xml.
Similarly maven.test.skip, you can define system property skipTests from command line or in pom.xml. Results: Only skips running tests, and Copying test resources, Compiling test sources phase will not be skipped. To not skip tests, use command $ mvn clean package -DskipTests=false. 3. Maven surefire plugin
Plugin Configuration and Goals Maven Enforcer has two goals: enforcer:enforce and enforcer:display-info. The enforce goal runs during a project build to execute rules specified in the configuration, while the display-info goal shows current information about the built-in rules that are present in the project's pom.xml.
The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules. The Enforcer plugin has two goals: enforcer:enforce executes rules for each project in a multi-project build.
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
In the POM of the module, set enforcer.skip
to true
:
<properties>
<enforcer.skip>true</enforcer.skip>
</properties>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With