Although I read the maven-enforcer-plugin
documentation, running mvn enforcer:enforce
always fails.
This is pom.xml
taken from the documentation
<?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>com.baz</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<name>foo</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<AlwaysPass/>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This is the execution and output of mvn enforcer:enforce
$ mvn enforcer:enforce
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.baz:foo >------------------------
[INFO] Building foo 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- enforcer:3.5.0:enforce (default-cli) @ foo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.229 s
[INFO] Finished at: 2024-08-26T11:19:54Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.5.0:enforce (default-cli) on project foo: No rules are configured. Use the skip flag if you want to disable execution. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Although the rules for maven-enforcer-plugin
exist in pom.xml
, it fails with No rules are configured
. Is this a bug or am I doing something incorrectly?
I guess you need to move the <configuration>
out of the <executions>
.