Author: vmassol
Date: Fri Mar 31 06:58:46 2006
New Revision: 390438

URL: http://svn.apache.org/viewcvs?rev=390438&view=rev
Log:
MCLOVEr-19, MCLOVER-25: clover:clover and clover:check now don't fork a 
lifecycle, they use an existing database. Introduce new clover:instrument mojo 
that does the fork. Users need to bind the instrument goal in their configs.

Added:
    
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
   (contents, props changed)
      - copied, changed from r390248, 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
    
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
   (with props)
Modified:
    
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-multiproject/pom.xml
    
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/pom.xml
    
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
    
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
    
maven/plugins/trunk/maven-clover-plugin/src/main/resources/META-INF/maven/lifecycle.xml

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-multiproject/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-multiproject/pom.xml?rev=390438&r1=390437&r2=390438&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-multiproject/pom.xml
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-multiproject/pom.xml
 Fri Mar 31 06:58:46 2006
@@ -19,13 +19,32 @@
     <plugins>
       <plugin>
         <artifactId>maven-clover-plugin</artifactId>
+<!--        <configuration>
+          <flushPolicy>threaded</flushPolicy>
+          <flushInterval>100</flushInterval>
+        </configuration>-->
+      </plugin>
+    </plugins>
+  </reporting>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-clover-plugin</artifactId>
         <configuration>
           <flushPolicy>threaded</flushPolicy>
           <flushInterval>100</flushInterval>
         </configuration>
+        <executions>
+          <execution>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>instrument</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
-  </reporting>
+  </build>
   <modules>
     <module>maven-clover-plugin-sample-multiproject-module1</module>
     <module>maven-clover-plugin-sample-multiproject-module2</module>

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/pom.xml?rev=390438&r1=390437&r2=390438&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/pom.xml
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/pom.xml
 Fri Mar 31 06:58:46 2006
@@ -42,8 +42,18 @@
         </configuration>
         <executions>
           <execution>
+            <id>main</id>
+            <phase>verify</phase>
             <goals>
+              <goal>instrument</goal>
               <goal>check</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>site</id>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>instrument</goal>
             </goals>
           </execution>
         </executions>

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java?rev=390438&r1=390437&r2=390438&view=diff
==============================================================================
--- 
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
 Fri Mar 31 06:58:46 2006
@@ -22,16 +22,11 @@
 import org.apache.tools.ant.Project;
 
 /**
- * Verify test percentage coverage and fail the build if it is below the 
defined threshold.
- *
- * Note: We're forking a lifecycle because we don't want the Clover 
instrumentation to affect the main lifecycle build.
- * This will prevent instrumented sources to be put in production by error. 
Thus running <code>mvn install</code> on
- * a project where this <code>check</code> goal has been specified will run 
the build twice: once for building the
- * project as usual and another time for instrumenting the sources with Clover 
and verifying the test coverage value.
+ * Verify test percentage coverage from an existing Clover database and fail 
the build if it is below the defined
+ * threshold.
  *
  * @goal check
  * @phase verify
- * @execute phase="test" lifecycle="clover"
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
  * @version $Id$
@@ -74,5 +69,4 @@
             throw new MojoExecutionException( e.getMessage(), e );
         }
     }
-
 }

Copied: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
 (from r390248, 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java)
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java?p2=maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java&p1=maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java&r1=390248&r2=390438&rev=390438&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
 Fri Mar 31 06:58:46 2006
@@ -20,7 +20,6 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
@@ -34,14 +33,14 @@
  *
  * Note: Do not call this MOJO directly. It is meant to be called in a forked 
lifecycle by the other MOJOs.
  *
- * @goal instrument
+ * @goal instrumentInternal
  * @phase generate-sources
  * @requiresDependencyResolution test
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
  * @version $Id$
  */
-public class CloverInstrumentMojo extends AbstractCloverMojo
+public class CloverInstrumentInternalMojo extends AbstractCloverMojo
 {
     /**
      * @parameter
@@ -119,7 +118,7 @@
 
         if ( !"java".equals( artifactHandler.getLanguage() ) )
         {
-            getLog().debug( "Not executing Clover as this is not a Java 
project." );
+            getLog().debug( "Not instrumenting sources with Clover as this is 
not a Java project." );
             shouldExecute = false;
         }
         else if ( !srcDir.exists() )

Propchange: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java?rev=390438&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
 (added)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
 Fri Mar 31 06:58:46 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.maven.plugin.clover;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Instrument all sources using Clover and forks a custom lifecycle to execute 
project's tests on the instrumented code
+ * so that a Clover database is created.
+ *
+ * Note: We're forking a lifecycle because we don't want the Clover 
instrumentation to affect the main lifecycle build.
+ * This will prevent instrumented sources to be put in production by error. 
Thus running <code>mvn install</code> on
+ * a project where this <code>instrument</code> goal has been specified will 
run the build twice: once for building the
+ * project as usual and another time for instrumenting the sources with Clover 
and generating the Clover database.
+ *
+ * @goal instrument
+ * @execute phase="test" lifecycle="clover"
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
+ * @version $Id$
+ */
+public class CloverInstrumentMojo extends AbstractCloverMojo
+{
+    public void execute()
+        throws MojoExecutionException
+    {
+    }
+}

Propchange: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java?rev=390438&r1=390437&r2=390438&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
 Fri Mar 31 06:58:46 2006
@@ -22,8 +22,6 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
-import org.apache.maven.model.Plugin;
-import org.apache.tools.ant.Project;
 import org.codehaus.doxia.sink.Sink;
 import org.codehaus.doxia.site.renderer.SiteRenderer;
 
@@ -31,12 +29,11 @@
 import java.util.*;
 
 /**
- * Generate a <a href="http://cenqua.com/clover";>Clover</a> report. The 
generated report is an external report
- * generated by Clover itself. If the project generating the report is a top 
level project and if the
- * <code>aggregate</code> configuration element is set to true then an 
aggregated report will also be created.
+ * Generate a <a href="http://cenqua.com/clover";>Clover</a> report from 
existing Clover databases. The generated report
+ * is an external report generated by Clover itself. If the project generating 
the report is a top level project and
+ * if the <code>aggregate</code> configuration element is set to true then an 
aggregated report will also be created.
  *
  * @goal clover
- * @execute phase="test" lifecycle="clover"
  * @aggregator
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
@@ -49,7 +46,7 @@
 
     /**
      * The location of the <a 
href="http://cenqua.com/clover/doc/adv/database.html";>Clover database</a>.
-     * 
+     *
      * @parameter expression="${project.build.directory}/clover/clover.db"
      * @required
      */
@@ -65,14 +62,14 @@
 
     /**
      * The directory where the Clover report will be generated.
-     * 
+     *
      * @parameter expression="${project.reporting.outputDirectory}/clover"
      * @required
      */
     private File outputDirectory;
 
     /**
-     * When the Clover Flush Policy is set to "interval" or threaded this 
value is the minimum 
+     * 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="500"
@@ -80,15 +77,15 @@
     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 
+     * 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.  
-     * 
+     * to them.
+     *
      * @parameter default-value="true"
      */
     protected boolean waitForFlush;
@@ -99,8 +96,8 @@
     private SiteRenderer siteRenderer;
 
     /**
-     * The Maven project. 
-     * 
+     * The Maven project.
+     *
      * @parameter expression="${project}"
      * @required
      * @readonly
@@ -133,16 +130,18 @@
         // http://jira.codehaus.org/browse/MNG-2188
         if ( canGenerateReport() )
         {
+            AbstractCloverMojo.waitForFlush( this.waitForFlush, 
this.flushInterval );
+
             // Only generate module level report for Java projects
             if ( isJavaProject(this.project) )
             {
-                AbstractCloverMojo.waitForFlush( this.waitForFlush, 
this.flushInterval );
                 createCloverHtmlReport();
             }
 
-            // If we're in the top level module and there are children 
modules, then create an extra report by
-            // aggregating the generated clover databases.
-            if ( this.aggregate && ( this.reactorProjects.size() > 1 ) )
+            // If we're in a module with children modules, then create an 
extra report by aggregating the children
+            // clover databases.
+getLog().info("yyyyyyy modules = " + getProject().getModules().size());
+            if ( this.aggregate && ( getProject().getModules().size() > 0 ) )
             {
                 // Ensure the merged database output directory exists
                 new File( this.cloverMergeDatabase ).getParentFile().mkdirs();
@@ -323,6 +322,10 @@
         for ( Iterator projects = this.reactorProjects.iterator(); 
projects.hasNext(); )
         {
             MavenProject project = (MavenProject) projects.next();
+getLog().info("YYYY | project = " + project.getName());
+getLog().info("YYYY | is java project = " + isJavaProject(project));
+getLog().info("YYYY | children clover db not empty = " + 
!getChildrenCloverDatabases().isEmpty());
+
             if ( isJavaProject(project) && 
!getChildrenCloverDatabases().isEmpty() )
             {
                 canGenerate = true;

Modified: 
maven/plugins/trunk/maven-clover-plugin/src/main/resources/META-INF/maven/lifecycle.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/resources/META-INF/maven/lifecycle.xml?rev=390438&r1=390437&r2=390438&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clover-plugin/src/main/resources/META-INF/maven/lifecycle.xml
 (original)
+++ 
maven/plugins/trunk/maven-clover-plugin/src/main/resources/META-INF/maven/lifecycle.xml
 Fri Mar 31 06:58:46 2006
@@ -11,7 +11,7 @@
               
<cloverDatabase>${project.build.directory}/clover/clover.db</cloverDatabase>
             </configuration>
             <goals>
-              <goal>instrument</goal>
+              <goal>instrumentInternal</goal>
             </goals>
           </execution>
         </executions>


Reply via email to