maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vmas...@apache.org
Subject svn commit: r390978 - in /maven/plugins/trunk/maven-clover-plugin: ./ src/it/maven-clover-plugin-sample-simple/ src/it/maven-clover-plugin-sample-simple/src/site/ src/main/java/org/apache/maven/plugin/clover/ src/main/java/org/apache/maven/plugin/clove...
Date Mon, 03 Apr 2006 08:08:30 GMT
Author: vmassol
Date: Mon Apr  3 01:08:28 2006
New Revision: 390978

URL: http://svn.apache.org/viewcvs?rev=390978&view=rev
Log:
MCLOVER-30: Add support for generating XML and PDF reports

Added:
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/
    maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/site.xml
  (with props)
    maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
  (with props)
    maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/internal/AbstractCloverMojo.java
  (contents, props changed)
      - copied, changed from r390676, maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
    maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/
    maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java
  (contents, props changed)
      - copied, changed from r390640, maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/CloverMojoTest.java
Removed:
    maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java
    maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/CloverMojoTest.java
Modified:
    maven/plugins/trunk/maven-clover-plugin/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/CloverAggregateMojo.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/CloverInstrumentInternalMojo.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/CloverLogMojo.java
    maven/plugins/trunk/maven-clover-plugin/src/site/apt/howto.apt

Modified: maven/plugins/trunk/maven-clover-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/pom.xml?rev=390978&r1=390977&r2=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-clover-plugin/pom.xml Mon Apr  3 01:08:28 2006
@@ -57,7 +57,7 @@
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-impl</artifactId>
-      <version>2.0</version>
+      <version>2.0.2</version>
     </dependency>
     <dependency>
       <groupId>clover</groupId>

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=390978&r1=390977&r2=390978&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
Mon Apr  3 01:08:28 2006
@@ -27,6 +27,10 @@
                build section inherits from the reporting section but not the other way around...
-->
           <cloverDatabase>${project.build.directory}/customclover/myclover.db</cloverDatabase>
 
+          <generateHtml>true</generateHtml>
+          <generatePdf>true</generatePdf>
+          <generateXml>true</generateXml>
+
         </configuration>
       </plugin>
     </plugins>

Added: maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/site.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/site.xml?rev=390978&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/site.xml
(added)
+++ maven/plugins/trunk/maven-clover-plugin/src/it/maven-clover-plugin-sample-simple/src/site/site.xml
Mon Apr  3 01:08:28 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*
+ * 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.
+ */
+-->
+
+<project name="Maven Clover Simple Sample">
+  <bannerLeft>
+    <name>Maven Clover Simple Sample</name>
+    <src>http://maven.apache.org/images/apache-maven-project.png</src>
+    <href>http://maven.apache.org/</href>
+  </bannerLeft>
+  <bannerRight>
+    <src>http://maven.apache.org/images/maven-small.gif</src>
+  </bannerRight>
+  <publishDate format="dd MMM yyyy" />
+  <body>
+    <links>
+      <item name="Maven" href="http://maven.apache.org/"/>
+    </links>
+
+    <menu name="Other Reports">
+      <item name="Clover PDF" href="clover/clover.pdf"/>
+      <item name="Clover XML" href="clover/clover.xml"/>
+    </menu>
+
+    ${reports}
+
+  </body>
+</project>

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

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

Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverAggregateMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverAggregateMojo.java?rev=390978&r1=390977&r2=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverAggregateMojo.java
(original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverAggregateMojo.java
Mon Apr  3 01:08:28 2006
@@ -2,6 +2,7 @@
 
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 
 import java.io.File;
 import java.util.*;
@@ -38,7 +39,7 @@
 
     /**
      * {@inheritDoc}
-     * @see org.apache.maven.plugin.clover.AbstractCloverMojo#execute()
+     * @see org.apache.maven.plugin.clover.internal.AbstractCloverMojo#execute()
      */
     public void execute()
         throws MojoExecutionException

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=390978&r1=390977&r2=390978&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
Mon Apr  3 01:08:28 2006
@@ -18,6 +18,7 @@
 import com.cenqua.clover.cfg.Percentage;
 import com.cenqua.clover.tasks.CloverPassTask;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
@@ -41,7 +42,7 @@
 
     /**
      * {@inheritDoc}
-     * @see org.apache.maven.plugin.clover.AbstractCloverMojo#execute()
+     * @see org.apache.maven.plugin.clover.internal.AbstractCloverMojo#execute()
      */
     public void execute()
         throws MojoExecutionException

Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java?rev=390978&r1=390977&r2=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
(original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentInternalMojo.java
Mon Apr  3 01:08:28 2006
@@ -20,6 +20,7 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
@@ -77,7 +78,7 @@
 
     /**
      * {@inheritDoc}
-     * @see org.apache.maven.plugin.clover.AbstractCloverMojo#execute()
+     * @see org.apache.maven.plugin.clover.internal.AbstractCloverMojo#execute()
      */
     public void execute()
         throws MojoExecutionException

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=390978&r1=390977&r2=390978&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
Mon Apr  3 01:08:28 2006
@@ -16,6 +16,7 @@
 package org.apache.maven.plugin.clover;
 
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 
 /**
  * Instrument all sources using Clover and forks a custom lifecycle to execute project's
tests on the instrumented code
@@ -36,7 +37,7 @@
 {
     /**
      * {@inheritDoc}
-     * @see org.apache.maven.plugin.clover.AbstractCloverMojo#execute()
+     * @see org.apache.maven.plugin.clover.internal.AbstractCloverMojo#execute()
      */
     public void execute()
         throws MojoExecutionException

Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverLogMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverLogMojo.java?rev=390978&r1=390977&r2=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverLogMojo.java
(original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverLogMojo.java
Mon Apr  3 01:08:28 2006
@@ -17,6 +17,7 @@
 
 import com.cenqua.clover.tasks.CloverLogTask;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 import org.apache.tools.ant.Project;
 
 /**

Added: 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=390978&view=auto
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
(added)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
Mon Apr  3 01:08:28 2006
@@ -0,0 +1,367 @@
+/*
+ * 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 com.cenqua.clover.reporters.html.HtmlReporter;
+import com.cenqua.clover.reporters.pdf.PDFReporter;
+import com.cenqua.clover.reporters.xml.XMLReporter;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReportException;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * 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.
+ *
+ * Note: This report mojo should be an @aggregator and the <code>clover:aggregate</code>
mojo shouldn't exist. This
+ * is a limitation of the site plugin which doesn't support @aggregator reports...
+ *
+ * @goal clover
+ *
+ * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
+ * @version $Id$
+ */
+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>.
+     *
+     * @parameter expression="${project.build.directory}/clover/clover.db"
+     * @required
+     */
+    private String cloverDatabase;
+
+    /**
+     * The location of the merged clover database to create when running a report in a multimodule
build.
+     *
+     * @parameter expression="${project.build.directory}/clover/cloverMerge.db"
+     * @required
+     */
+    private String cloverMergeDatabase;
+
+    /**
+     * 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
+     * period between flush operations (in milliseconds).
+     *
+     * @parameter default-value="500"
+     */
+    private 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"
+     */
+    private boolean waitForFlush;
+
+    /**
+     * Decide whether to generate an HTML report
+     * @parameter default-value="true"
+     */
+    private boolean generateHtml;
+
+    /**
+     * Decide whether to generate a PDF report
+     * @parameter default-value="false"
+     */
+    private boolean generatePdf;
+
+    /**
+     * Decide whether to generate a XML report
+     * @parameter default-value="false"
+     */
+    private boolean generateXml;
+
+    /**
+     * @component
+     */
+    private Renderer siteRenderer;
+
+    /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * The projects in the reactor for aggregation report.
+     *
+     * @parameter expression="${reactorProjects}"
+     * @readonly
+     */
+    private List reactorProjects;
+
+    /**
+     * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
+     */
+    public void executeReport( Locale locale ) throws MavenReportException
+    {
+        // Ensure the output directory exists
+        this.outputDirectory.mkdirs();
+
+        File singleModuleCloverDatabase = new File( this.cloverDatabase );
+        if ( singleModuleCloverDatabase.exists() )
+        {
+            if ( this.generateHtml )
+            {
+                createHtmlReport();
+            }
+            if ( this.generatePdf )
+            {
+                createPdfReport();
+            }
+            if ( this.generateXml )
+            {
+                createXmlReport();
+            }
+        }
+
+        File mergedCloverDatabase = new File ( this.cloverMergeDatabase );
+        if ( mergedCloverDatabase.exists() )
+        {
+            if ( this.generateHtml )
+            {
+                createMasterHtmlReport();
+            }
+            if ( this.generatePdf )
+            {
+                createMasterPdfReport();
+            }
+            if ( this.generateXml )
+            {
+                createMasterXmlReport();
+            }
+        }
+    }
+
+    private List getCommonCliArgs( File reportOutputFile )
+    {
+        List parameters = new ArrayList();
+
+        parameters.add( "-t" );
+        parameters.add( "Maven Clover report" );
+        parameters.add( "-i" );
+        parameters.add( this.cloverDatabase );
+        parameters.add( "-o" );
+        parameters.add( reportOutputFile.getPath() );
+
+        if ( getLog().isDebugEnabled() )
+        {
+            parameters.add( "-d" );
+        }
+
+        return parameters;
+    }
+
+    /**
+     * @todo handle multiple source roots. At the moment only the first source root is instrumented
+     */
+    private void createHtmlReport() throws MavenReportException
+    {
+        List parameters = getCommonCliArgs( this.outputDirectory );
+
+        parameters.add( "-p" );
+        parameters.add( this.project.getCompileSourceRoots().get( 0 ) );
+
+        createReport(HtmlReporter.class, parameters, "HTML");
+    }
+
+    private void createPdfReport() throws MavenReportException
+    {
+        createReport(PDFReporter.class, getCommonCliArgs( new File( this.outputDirectory,
"clover.pdf" ) ), "PDF");
+    }
+
+    private void createXmlReport() throws MavenReportException
+    {
+        createReport(XMLReporter.class, getCommonCliArgs( new File( this.outputDirectory,
"clover.xml" ) ), "XML");
+    }
+
+    private void createReport( Class reportClass, List parameters, String reportType )
+        throws MavenReportException
+    {
+        int result;
+        try
+        {
+            result = ((Integer) reportClass.getMethod( "mainImpl", new Class[]{String[].class}).invoke(null,
+                new Object[]{(String[]) parameters.toArray( new String[0] )} )).intValue();
+        }
+        catch (Exception e)
+        {
+            throw new MavenReportException( "Failed to call [" + reportClass.getName() +
".mainImpl]", e );
+        }
+
+        if ( result != 0 )
+        {
+            throw new MavenReportException( "Clover has failed to create the " + reportType
+ " report" );
+        }
+    }
+
+    private List getCommonCliArgsForMasterReport( File reportOutputFile )
+    {
+        List parameters = new ArrayList();
+
+        parameters.add( "-t" );
+        parameters.add( "Maven Aggregated Clover report" );
+        parameters.add( "-i" );
+        parameters.add( this.cloverMergeDatabase );
+        parameters.add( "-o" );
+        parameters.add( reportOutputFile );
+
+        if ( getLog().isDebugEnabled() )
+        {
+            parameters.add( "-d" );
+        }
+
+        return parameters;
+    }
+
+    private void createMasterHtmlReport() throws MavenReportException
+    {
+        createReport(HtmlReporter.class, getCommonCliArgsForMasterReport( this.outputDirectory
), "merged HTML");
+    }
+
+    private void createMasterPdfReport() throws MavenReportException
+    {
+        createReport(PDFReporter.class, getCommonCliArgsForMasterReport(
+            new File( this.outputDirectory, "cloverMerged.pdf" ) ), "merged PDF");
+    }
+
+    private void createMasterXmlReport() throws MavenReportException
+    {
+        createReport(XMLReporter.class, getCommonCliArgsForMasterReport(
+            new File( this.outputDirectory, "cloverMerged.xml" ) ), "merged XML");
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getOutputName()
+     */
+    public String getOutputName()
+    {
+        return "clover/index";
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
+     */
+    public String getDescription( Locale locale )
+    {
+        return getBundle( locale ).getString( "report.clover.description" );
+    }
+
+    private static ResourceBundle getBundle( Locale locale )
+    {
+        return ResourceBundle.getBundle( "clover-report", locale, CloverReportMojo.class.getClassLoader()
);
+    }
+
+    /**
+     * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
+     */
+    protected String getOutputDirectory()
+    {
+        return this.outputDirectory.getAbsoluteFile().toString();
+    }
+
+    /**
+     * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
+     */
+    protected Renderer getSiteRenderer()
+    {
+        return this.siteRenderer;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.AbstractMavenReport#getProject()
+     */
+    protected MavenProject getProject()
+    {
+        return this.project;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
+     */
+    public String getName( Locale locale )
+    {
+        return getBundle( locale ).getString( "report.clover.name" );
+    }
+
+    /**
+     * Always return true as we're using the report generated by Clover rather than creating
our own report.
+     * @return true
+     */
+    public boolean isExternalReport()
+    {
+        return true;
+    }
+
+    /**
+     * Generate reports if a Clover module database or a Clover merged database exist.
+     *
+     * @return true if a project should be generated
+     * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
+     */
+    public boolean canGenerateReport()
+    {
+        boolean canGenerate = false;
+
+        AbstractCloverMojo.waitForFlush( this.waitForFlush, this.flushInterval );
+
+        File singleModuleCloverDatabase = new File( this.cloverDatabase );
+        File mergedCloverDatabase = new File ( this.cloverMergeDatabase );
+
+        if (singleModuleCloverDatabase.exists() || mergedCloverDatabase.exists() )
+        {
+            if ( this.generateHtml || this.generatePdf || this.generateXml )
+            {
+                canGenerate = true;
+            }
+        }
+        else
+        {
+            getLog().warn("No Clover database found, skipping report generation");
+        }
+
+        return canGenerate;
+    }
+}

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

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

Copied: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/internal/AbstractCloverMojo.java
(from r390676, 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/internal/AbstractCloverMojo.java?p2=maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/internal/AbstractCloverMojo.java&p1=maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java&r1=390676&r2=390978&rev=390978&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/internal/AbstractCloverMojo.java
Mon Apr  3 01:08:28 2006
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.maven.plugin.clover;
+package org.apache.maven.plugin.clover.internal;
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;

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

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

Modified: maven/plugins/trunk/maven-clover-plugin/src/site/apt/howto.apt
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/site/apt/howto.apt?rev=390978&r1=390977&r2=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/site/apt/howto.apt (original)
+++ maven/plugins/trunk/maven-clover-plugin/src/site/apt/howto.apt Mon Apr  3 01:08:28 2006
@@ -67,6 +67,70 @@
   module reports into a master Clover report, run <<<mvn clover:instrument clover:aggregate
clover:clover>>>
   instead.
 
+Generating HTML, XML and PDF reports
+
+  By default the Clover plugin will generate a HTML report. If you want to generate a PDF
or XML report, or
+  if you simply do not want to generate the HTML report use the <<<generateHtml>>>,
<<<generatePdf>>> and
+  <<<generateXml>>> configuration elements. By default the <<<generateHtml>>>
element is set to true.
+  For example if you wish to generate the PDF and XML reports you would use:
+
++--------
+[...]
+  <plugin>
+    <groupId>org.apache.maven.plugins</groupId>
+    <artifactId>maven-clover-plugin</artifactId>
+    <configuration>
+      <generatePdf>true</generatePdf>
+      <generateXml>true</generateXml>
+    </configuration>
+  </plugin>
+[...]
++---------
+
+  Note that only the HTML report gets a link in the "Project Reports" section in generated
menu on the site. If
+  you want to link the PDF or XML reports you'll need to do that by modifying your <<<site.xml>>>.
For example:
+
++--------
+[...]
+  <menu name="Other Reports">
+    <item name="Clover PDF" href="clover/clover.pdf"/>
+    <item name="Clover XML" href="clover/clover.xml"/>
+  </menu>
+[...]
++---------
+
+  If you do not want to generate the HTML report then you should not configure the Clover
plugin in the
+  <<<reporting>>> section as this section is for plugins which generate
HTML reports. In that case, simply
+  bind the <<<clover:clover>>> goal to the <<<site>>>
phase in the <<<build>>> section. For example:
+
++--------
+<project>
+  [...]
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-clover-plugin</artifactId>
+        <configuration>
+          <generateHtml>false</generateHtml>
+          <generatePdf>true</generatePdf>
+          <generateXml>true</generateXml>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>site</phase>
+            <goals>
+              <goal>instrument</goal>
+              <goal>clover</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+[...]
++---------
+
 Checking test coverage
 
   In order to check for a test coverage percentage and fail the build in case of non-compliance,

Copied: maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java
(from r390640, maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/CloverMojoTest.java)
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java?p2=maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java&p1=maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/CloverMojoTest.java&r1=390640&r2=390978&rev=390978&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/CloverMojoTest.java
(original)
+++ maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java
Mon Apr  3 01:08:28 2006
@@ -13,17 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.maven.plugin.clover;
+package org.apache.maven.plugin.clover.internal;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.clover.internal.Locator;
+import org.apache.maven.plugin.clover.internal.AbstractCloverMojo;
 import org.jmock.MockObjectTestCase;
 import org.jmock.Mock;
 
 import java.io.File;
 
 /**
- * Unit tests for {@link org.apache.maven.plugin.clover.AbstractCloverMojo}.
+ * Unit tests for {@link org.apache.maven.plugin.clover.internal.AbstractCloverMojo}.
  * 
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
  * @version $Id$

Propchange: maven/plugins/trunk/maven-clover-plugin/src/test/java/org/apache/maven/plugin/clover/internal/CloverMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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



Mime
View raw message