Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven enforcer plugin missing or invalid rules

I am trying to setup the enforcer plugin for maven to enforce a minimum Java version. However, whenever I try to run mvn enforcer:enforce, I get:

The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or invalid

Here is the relevant portion of my pom file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.3.1</version>
    <executions>
        <execution>
            <id>enforce-java</id>
            <phase>validate</phase>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <requireJavaVersion>
                        <version>(1.7.0-20,)</version>
                    </requireJavaVersion>
                </rules>
            </configuration>
        </execution>
    </executions>
</plugin>

I also tried replacing the <requireJavaVersion> block with <alwaysPass/>, in case something was invalid, but it still failed with the same error.

like image 702
X3no Avatar asked Jul 18 '14 14:07

X3no


1 Answers

It may be that you are using invalid rule names. Check out the rules page. The rule names are case sensitive. Though this is not the case here.

---- Edit ----

Note that the POM configuration has an execution ID of enforce-java and that execution is bound to the validate phase of the lifecycle. The command mvn enforcer:enforce is running a goal, not a phase in the lifecycle. The configuration you provided in the POM doesn't apply to the enforcer:enforce goal.

There are two ways to make this work. Which one you choose depends on what you need.

  1. If you are just trying to test the enforcer plugin configuration without running the whole build, run mvn validate.
  2. If the requirement is that mvn enforcer:enforce works, then change the execution ID to default-cli.
like image 88
user944849 Avatar answered Nov 06 '22 06:11

user944849