[MENFORCER-397] allow no rules - ASF Jira (original) (raw)

Allow no rules by adding property similar to http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#failIfNoTests

Currently the execution fails

No rules are configured. Use the skip flag if you want to disable execution.

For some background, my strategy in dealing with lots of XML is to configure plugin executions upfront with an id, goal, and default properties, and then allow modules to populate them with the minimum e.g.

      <executions>
        <execution>
          <id>fail</id>
          <goals>
            <goal>enforce</goal>
          </goals>
          <configuration>
            <fail>true</fail>
          </configuration>
        </execution>
        <execution>
          <id>warn</id>
          <goals>
            <goal>enforce</goal>
          </goals>
          <configuration>
            <fail>false</fail>
          </configuration>
        </execution>
      </executions>

and then

        <executions>
          <execution>
            <id>warn</id>
            <configuration>
              <rules>
                <requireProperty>
                  <property>remote.name</property>
                  <message>Distribution profile invoked without setting a remote.name: repositories may not be configured correctly</message>
                </requireProperty>
              </rules>
            </configuration>
          </execution>
        </executions>