disable maven enforcer rule
Apache maven enforcer rules are very useful in large projects. A common usage of such enforcer rules is to define them in a central point like a project parent pom.xml. For example following enforcer definition can be set in a pom parent:
package-parent pom.xml:
... <plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-java-1_4</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireProperty> <property>java.compiler.version</property> <regex>1\.4</regex> <regexMessage>You must compile with Java 1.4, as long our servers run in old NetWeaver!</regexMessage> </requireProperty> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> ...
This enforcer rule should ensure that all projects, which using the parent POM using a Java 1.4 compiler.
Often such parent pom defines many other useful properties and settings for projects. If you want to use these definition and ONLY want to disable the enforcer rule you can simple do follow „trick“:
... <parent> <groupId>org.waffel</groupId> <artifactId>package-parent</artifactId> <version>1.1</version> </parent> <build> <plugins> <!-- we need to overide the enforcer rules here because we have java 1.6 and not the old 1.4 --> <plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-java-1_4</id> <phase>none</phase> </execution> </executions> </plugin> </plugins> </build> ...
I use the same approach here as described in my article how to diable a inherited maven plugin.
Filed under: software Tagged: disable, enforcer, maven, plugin, rule