You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ji...@codehaus.org on 2004/03/19 01:49:47 UTC

[jira] Commented: (MPCLOVER-6) historical report for clover

The following comment has been added to this issue:

     Author: Nick Minutello
    Created: Thu, 18 Mar 2004 7:47 PM
       Body:
Hmmm. This seems to have been dealt with promptly...

Should the historical report be a new maven report? Should it be a plugin on its own?
---------------------------------------------------------------------
View this comment:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPCLOVER-6&page=comments#action_17712

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPCLOVER-6

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPCLOVER-6
    Summary: historical report for clover
       Type: Improvement

     Status: Unassigned
   Priority: Minor

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: maven-clover-plugin
   Fix Fors:
             1.5
   Versions:
             1.2

   Assignee: 
   Reporter: Simon Matic Langford

    Created: Tue, 22 Jul 2003 3:34 AM
    Updated: Thu, 18 Mar 2004 7:47 PM
Environment: clover required

Description:
Does a historical clover report if there are results spanning more than one day.

Changes to "plugin.jelly":
========================
37a38,42
>       <doc:registerReport
>         name="Clover Historical"
>         pluginName="maven-clover-plugin"
>         link="clover-history/historical"
>         description="Clover test coverage historical report."/>
48a54
>     <attainGoal name="clover:historic-report"/>
82a89,92
>
>     <j:set
>       var="cloverHistoryReportDirectory"
>       value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.dest')}/clover-history"/>
89a100
>     <ant:mkdir dir="${cloverHistoryReportDirectory}"/>
126c137
<       <current
---
>       <ant:current
130c141
<       </current>
---
>       </ant:current>
150a162,192
>
>   <goal
>     name="clover:historic-report"
>     description="Generate HTML test coverage reports with Clover">
>         <attainGoal name="clover:test"/>
>         <ant:clover-historypoint historyDir="${maven.clover.historic.dir}"/>
>         <attainGoal name="java:compile"/>
>       <ant:taskdef name="check-clover-history"
>           classname="org.apache.maven.clover.CheckCloverHistoryTask"
>           classpath="${maven.build.dest}"
>       />
>     <ant:check-clover-history
>       historyDir="${maven.clover.historic.dir}"
>       property="cloverHistoryOk"
>       value="true"
>     />
>     <j:if test="${cloverHistoryOk == 'true'}">
>       <ant:clover-report>
>         <ant:historical
>               title="${pom.name} - ${pom.currentVersion}"
>               outfile="${cloverHistoryReportDirectory}"
>               historyDir="${maven.clover.historic.dir}">
>               <ant:overview />
>               <ant:coverage />
>               <ant:metrics />
>               <ant:movers range="10" interval="1w" />
>           <ant:format type="html" orderBy="ElementsCoveredAsc"/>
>         </ant:historical>
>       </ant:clover-report>
>     </j:if>
>   </goal>

New Ant task "org/apache/maven/clover/CheckCloverHistoryTask.java":
===========================================
package org.apache.maven.clover;

import java.io.IOException;
import java.io.File;
import java.util.Vector;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;

/**
 * @author <a href="mailto:simon@exemel.co.uk">Simon Matic Langford</a>
 * @version 1.0
 */
public class CheckCloverHistoryTask extends Task
{
  /**
   * Location of the clover history files.
   */
  private String historyDir = null;
  /**
   * Property to set if 2 or more days of data found.
   */
  private String property = null;
  /**
   * Value of property to set if 2 or more days of data found.
   */
  private String value = null;

  /**
   * @see #historyDir
   */
  public String getHistoryDir()
  {
    return historyDir;
  }

  /**
   * @see #historyDir
   */
  public void setHistoryDir(String historyDir)
  {
    this.historyDir = historyDir;
  }

  /**
   * @see #property
   */
  public String getProperty()
  {
    return property;
  }

  /**
   * @see #property
   */
  public void setProperty(String property)
  {
    this.property = property;
  }

  /**
   * @see #value
   */
  public String getValue()
  {
    return value;
  }

  /**
   * @see #value
   */
  public void setValue(String value)
  {
    this.value = value;
  }

  /**
   * Sets the property if at least 2 seperate days of clover
   * history data found.
   */
  public void execute() throws BuildException
  {
    File dir = new File(historyDir);
    String[] filenames = dir.list();
    Vector v = new Vector();
    for (int i=0; i<filenames.length; i++)
    {
      String date = getDateBit(filenames[i]);
      if (v.contains(date))
      {
        getProject().setProperty(property,value);
        log("Found 2 different days.");
        return;
      }
      else
      {
        v.addElement(date);
      }
    }
    log("Found only 1 day.");
  }

  /**
   * Gets the date part of a clover history file, in the form <code>clover-20030721151309.xml</code>.
   */
  private String getDateBit(String filename)
  {
    // clover-20030721151309.xml
    int i = filename.indexOf("-")+1;
    return filename.substring(i,i+8);
  }
}


Changes to "plugin.properties":
=============================
maven.clover.historic.dir = ${maven.build.clover}/historic




---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org