Author: vmassol
Date: Thu Oct 12 04:08:46 2006
New Revision: 463191

URL: http://svn.apache.org/viewvc?view=rev&rev=463191
Log:
MCLOVER-38: Allow check Mojo to be overriden by a failOnViolation parameter in 
the same way PMD and Checkstyle can

Modified:
    
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
    maven/plugins/trunk/maven-clover-plugin/src/site/apt/usage.apt

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java?view=diff&rev=463191&r1=463190&r2=463191
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
 Thu Oct 12 04:08:46 2006
@@ -50,7 +50,16 @@
      * @parameter
      */
     private String contextFilters;
-    
+
+    /**
+     * Do we fail the build on a violation? The default is true but there are 
some edge cases where you want to be
+     * able to check what would fail but without actually failing the build. 
For example you may want to let the build
+     * continue so that you can verify others checks that are executed after 
the Clover checks. 
+     *
+     * @parameter expression="${failOnViolation}" default-value="true"
+     */
+    private boolean failOnViolation;
+
     /**
      * [EMAIL PROTECTED]
      * @see 
org.apache.maven.plugin.clover.internal.AbstractCloverMojo#execute()
@@ -122,9 +131,17 @@
         catch ( BuildException e )
         {
             getLog().error( antProject.getProperty( "clovercheckproperty" ) );
-            throw new MojoExecutionException( e.getMessage(), e );
-        }
 
+            if ( this.failOnViolation )
+            {
+                throw new MojoExecutionException( e.getMessage(), e );
+            }
+            else
+            {
+                getLog().warn( "Clover test percentage coverage is below 
threshold but failOnViolation is set to "
+                    + " false, preventing the build from failing." );
+            }
+        }
     }
 
     /**

Modified: maven/plugins/trunk/maven-clover-plugin/src/site/apt/usage.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clover-plugin/src/site/apt/usage.apt?view=diff&rev=463191&r1=463190&r2=463191
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-clover-plugin/src/site/apt/usage.apt Thu Oct 12 
04:08:46 2006
@@ -206,6 +206,15 @@
   Note: The <<<clover:check>>> goal will also check the test percentage 
coverage
   for merged Clover databases if any is found (see the
   {{{usage.html#Aggregating Clover Reports}Aggregating Clover Reports}} 
section for more on that).
+
+  There are some special cases where you'd want the build not to fail even 
though the TPC is below the expected
+  threshold (for example to let the build continue so that you can see the 
results of other checks prior to
+  fixing the TPC). There's a <<<failOnViolation>>> configuration property for 
this which you can also run on the
+  command line as follows:
+
++------+
+  mvn clover:instrument clover:check -DtargetPercentage=50% 
-DfailOnViolation=false
++------+
  
   <Back to {{{usage.html}top}}.>
   


Reply via email to