You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vm...@apache.org on 2005/10/27 01:19:00 UTC

svn commit: r328760 - in /maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover: AbstractCloverMojo.java CloverCheckMojo.java CloverInstrumentMojo.java

Author: vmassol
Date: Wed Oct 26 16:18:55 2005
New Revision: 328760

URL: http://svn.apache.org/viewcvs?rev=328760&view=rev
Log:
MNG-618: We know make sure test coverage data is flushed before running the test coverage check.

Modified:
    maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
    maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
    maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java

Modified: maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java?rev=328760&r1=328759&r2=328760&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java Wed Oct 26 16:18:55 2005
@@ -38,9 +38,23 @@
      * When the Clover Flush Policy is set to "interval" or threaded this value is the minimum 
      * period between flush operations (in milliseconds).
      *
-     * @parameter default-value="5000"
+     * @parameter default-value="500"
      */
     protected int flushInterval;
+
+    /**
+     * If true we'll wait 2*flushInterval to ensure coverage data is flushed to the Clover 
+     * database before running any query on it. 
+     * 
+     * Note: The only use case where you would want to turn this off is if you're running your 
+     * tests in a separate JVM. In that case the coverage data will be flushed by default upon
+     * the JVM shutdown and there would be no need to wait for the data to be flushed. As we
+     * can't control whether users want to fork their tests or not, we're offering this parameter
+     * to them.  
+     * 
+     * @parameter default-value="true"
+     */
+    protected boolean waitForFlush;
     
     /**
      * Whether the Clover instrumentation should use the Clover <code>jdk14</code> or
@@ -80,4 +94,21 @@
         return antProject;
     }
 
+    /**
+     * Wait 2*'flush interval' milliseconds to ensure that the coverage data have been flushed.
+     */
+    protected void waitForFlush()
+    {
+        if ( this.waitForFlush )
+        {
+            try
+            {
+                Thread.sleep( 2 * this.flushInterval );
+            }
+            catch ( InterruptedException e )
+            {
+                // Nothing to do... Just go on and try to check for coverage.
+            }
+        }
+    }
 }

Modified: maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java?rev=328760&r1=328759&r2=328760&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java Wed Oct 26 16:18:55 2005
@@ -50,6 +50,8 @@
     public void execute()
         throws MojoExecutionException
     {
+        waitForFlush();
+
         Project antProject = registerCloverAntTasks();
 
         getLog().info( "Checking for coverage of " + targetPercentage);

Modified: maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java?rev=328760&r1=328759&r2=328760&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java Wed Oct 26 16:18:55 2005
@@ -141,9 +141,9 @@
                                                  cloverArtifact.getType() );
 
         // TODO: use addArtifacts
-        Set set = new HashSet( project.getDependencyArtifacts() );
+        Set set = new HashSet( this.project.getDependencyArtifacts() );
         set.add( cloverArtifact );
-        project.setDependencyArtifacts( set );
+        this.project.setDependencyArtifacts( set );
     }
 
     /**