[MENFORCER-397] allow no rules
diff --git a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
index ca5e221..da9a4ac 100644
--- a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
+++ b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
@@ -98,6 +98,14 @@
     private boolean failFast = false;
 
     /**
+     * Flag to fail the build if no rules are present
+     *
+     * @since 3.1.1
+     */
+    @Parameter( property = "enforcer.failIfNoRules", defaultValue = "true" )
+    private boolean failIfNoRules = true;
+
+    /**
      * Array of objects that implement the EnforcerRule interface to execute.
      */
     @Parameter( required = false )
@@ -153,9 +161,17 @@
 
         if ( !havingRules() )
         {
-            // CHECKSTYLE_OFF: LineLength
-            throw new MojoExecutionException( "No rules are configured. Use the skip flag if you want to disable execution." );
-            // CHECKSTYLE_ON: LineLength
+            if ( isFailIfNoRules() )
+            {
+                // CHECKSTYLE_OFF: LineLength
+                throw new MojoExecutionException( "No rules are configured. Use the skip flag if you want to disable execution." );
+                // CHECKSTYLE_ON: LineLength
+            }
+            else
+            {
+                log.warn( "No rules are configured." );
+                return;
+            }
         }
 
         // messages with warn/error flag
@@ -400,6 +416,22 @@
     }
 
     /**
+     * @return the failIfNoRules
+     */
+    public boolean isFailIfNoRules()
+    {
+        return this.failIfNoRules;
+    }
+
+    /**
+     * @param thefailIfNoRules the failIfNoRules to set
+     */
+    public void setFailIfNoRules( boolean thefailIfNoRules )
+    {
+        this.failIfNoRules = thefailIfNoRules;
+    }
+
+    /**
      * @return the project
      */
     public MavenProject getProject()
diff --git a/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java b/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
index 5dcbb91..093c9fa 100644
--- a/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
+++ b/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
@@ -300,6 +300,20 @@
         Mockito.verify( logSpy ).warn( Mockito.matches( ".* failed with message:" + System.lineSeparator() + "null" ) );
     }
 
+    @Test
+    public void testFailIfNoTests()
+            throws MojoExecutionException {
+        setupBasics( false );
+        mojo.setFailIfNoRules( false );
+
+        Log logSpy = setupLogSpy();
+
+        mojo.execute();
+
+        Mockito.verify( logSpy ).warn( Mockito.eq( "No rules are configured." ) );
+        Mockito.verifyNoMoreInteractions( logSpy );
+    }
+
     private void setupBasics( boolean fail )
     {
         mojo.setFail( fail );