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/12/23 18:14:02 UTC

svn commit: r358835 - in /maven/plugins/trunk/maven-clover-plugin/src: it/maven-clover-plugin-sample-mulitproject/ it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/ it/maven-clover-plugin-sample-mulitproject/ma...

Author: vmassol
Date: Fri Dec 23 09:13:45 2005
New Revision: 358835

URL: http://svn.apache.org/viewcvs?rev=358835&view=rev
Log:
Progressed on fixing MCLOVER-5:

- Removed @readonly javadoc tag in CloverInstrumentMojo. For some reason this is causing an error when run in a reactor. No idea why. If someone knows please let me know so that I can document it.
- Added it tests for running clover site in multiprojects
- Fixed report mojo: we need to wait for clover to have flushed its coverage data (a leftover from MCLOVER-4)

Note 1: I have no idea how to share more code betwee report mojos and main build mojos. See http://jira.codehaus.org/browse/MNG-1886. Any idea is most welcome.
Note 2: The multiproject build is still not fully working as the generated does not container the clover report. Still trying to figure out why...

Added:
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml   (with props)
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java   (with props)
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java   (with props)
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml   (with props)
Modified:
    maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
    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/CloverInstrumentMojo.java
    maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java

Added: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml?rev=358835&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml (added)
+++ maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml Fri Dec 23 09:13:45 2005
@@ -0,0 +1,13 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.plugins</groupId>
+    <artifactId>maven-clover-plugin-sample-multiproject</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>maven-clover-plugin-sample-multiproject-module1</artifactId>
+  <packaging>jar</packaging>
+  <name>Maven Clover Plugin Multiproject Sample - Module 1</name>
+  <description>Maven Clover Plugin Multiproject Sample - Module 1</description>
+  <version>1.0-SNAPSHOT</version>
+</project>

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java?rev=358835&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java (added)
+++ maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java Fri Dec 23 09:13:45 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005 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.samples.multiproject;
+
+public class Simple
+{
+    public void someMethod()
+    {
+        int i = 0;
+        if (i > 0)
+        {
+            i = i + 1;
+        }
+    }
+}

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/main/java/org/apache/maven/plugin/clover/samples/multiproject/Simple.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java?rev=358835&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java (added)
+++ maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java Fri Dec 23 09:13:45 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005 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.samples.multiproject;
+
+import junit.framework.TestCase;
+
+public class SimpleTest extends TestCase
+{
+    public void testSomeMethod()
+    {
+        Simple simple = new Simple();
+        simple.someMethod();
+    }
+}
+ 
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/maven-clover-plugin-sample-multiproject-module1/src/test/java/org/apache/maven/plugin/clover/samples/multiproject/SimpleTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml?rev=358835&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml (added)
+++ maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml Fri Dec 23 09:13:45 2005
@@ -0,0 +1,33 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-clover-plugin-sample-multiproject</artifactId>
+  <packaging>pom</packaging>
+  <name>Maven Clover Plugin Multiproject Sample</name>
+  <description>Maven Clover Plugin Multiproject Sample</description>
+  <version>1.0-SNAPSHOT</version>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <reporting>
+    <excludeDefaults>true</excludeDefaults>
+    <plugins>
+      <plugin>
+        <artifactId>maven-clover-plugin</artifactId>
+        <configuration>
+          <flushPolicy>threaded</flushPolicy>
+          <flushInterval>100</flushInterval>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+  <modules>
+    <module>maven-clover-plugin-sample-multiproject-module1</module>
+    <module>maven-clover-plugin-sample-multiproject-module2</module>
+  </modules>
+</project>

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-mulitproject/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java?rev=358835&r1=358834&r2=358835&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java (original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java Fri Dec 23 09:13:45 2005
@@ -97,14 +97,17 @@
 
     /**
      * Wait 2*'flush interval' milliseconds to ensure that the coverage data have been flushed.
+     * 
+     * TODOe: This method should not be static but we need it static because cannot share code 
+     * between non report mojos and main build mojos. See http://jira.codehaus.org/browse/MNG-1886 
      */
-    protected void waitForFlush()
+    public static void waitForFlush(boolean waitForFlush, int flushInterval) 
     {
-        if ( this.waitForFlush )
+        if ( waitForFlush )
         {
             try
             {
-                Thread.sleep( 2 * this.flushInterval );
+                Thread.sleep( 2 * flushInterval );
             }
             catch ( InterruptedException e )
             {

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=358835&r1=358834&r2=358835&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 Dec 23 09:13:45 2005
@@ -50,7 +50,7 @@
     public void execute()
         throws MojoExecutionException
     {
-        waitForFlush();
+        AbstractCloverMojo.waitForFlush( this.waitForFlush, this.flushInterval );
 
         Project antProject = registerCloverAntTasks();
 

Modified: 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=358835&r1=358834&r2=358835&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/CloverInstrumentMojo.java Fri Dec 23 09:13:45 2005
@@ -49,6 +49,8 @@
     private String cloverOutputDirectory;
 
     /**
+     * The location of the <a href="http://cenqua.com/clover/doc/adv/database.html">Clover database</a>.
+     * 
      * @parameter
      * @required
      */
@@ -57,7 +59,6 @@
     /**
      * @parameter expression="${project}"
      * @required
-     * @readonly
      */
     private MavenProject project;
 

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=358835&r1=358834&r2=358835&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 Dec 23 09:13:45 2005
@@ -19,7 +19,6 @@
 import com.cenqua.clover.reporters.html.HtmlReporter;
 
 import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
@@ -41,6 +40,9 @@
 public class CloverReportMojo
     extends AbstractMavenReport
 {
+    // TODO: Need some way to share config elements and code between report mojos and main build
+    // mojos. See http://jira.codehaus.org/browse/MNG-1886
+    
     /**
      * The location of the <a href="http://cenqua.com/clover/doc/adv/database.html">Clover database</a>.
      * 
@@ -58,6 +60,28 @@
     private String outputDirectory;
 
     /**
+     * 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"
+     */
+    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;
+    
+    /**
      * @component
      */
     private SiteRenderer siteRenderer;
@@ -84,6 +108,8 @@
             getLog().debug( "Not generating a Clover report as this is not a Java project." );
             return;
         }
+
+        AbstractCloverMojo.waitForFlush( this.waitForFlush, this.flushInterval );
         
         int result = HtmlReporter.mainImpl( createCliArgs() );
         if ( result != 0 )
@@ -98,8 +124,11 @@
      */
     private String[] createCliArgs()
     {
-        return new String[]{"-t", "Maven Clover report", "-p", (String) this.project.getCompileSourceRoots().get( 0 ),
-            "-i", this.cloverDatabase, "-o", this.outputDirectory};
+        return new String[]{
+            "-t", "Maven Clover report", 
+            "-p", (String) this.project.getCompileSourceRoots().get( 0 ),
+            "-i", this.cloverDatabase, 
+            "-o", this.outputDirectory};
     }
 
     public String getOutputName()
@@ -159,23 +188,6 @@
         throws MavenReportException
     {
         executeReport( locale );
-    }
-
-    /**
-     * @see org.apache.maven.plugin.Mojo#execute()
-     */
-    public void execute()
-        throws MojoExecutionException
-    {
-        try
-        {
-            generate( null, Locale.ENGLISH );
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException(
-                "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
-        }
     }
 
     public boolean isExternalReport()