changeset 25:e6fd2f1eba13

add sonar with clover coverage
author smith@nwoca.org
date Thu, 07 Apr 2011 19:14:15 -0400
parents a63acb4e09f8
children 639bec4999f2
files clover-ant.xml sonar-ant.xml
diffstat 2 files changed, 59 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/clover-ant.xml	Thu Apr 07 19:14:15 2011 -0400
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="clover-project-tasks" default="" basedir="."
+         xmlns:ivy="antlib:fr.jayasoft.ivy.ant"
+         xmlns:ssdt="http://www.ssdt-ohio.org/ant/common">
+
+    <description>Clover Ant tasks</description>
+    
+
+    <target name="-check.clover">
+        <property           name="clover.jar.file" value="${user.home.ant.lib}/clover.jar}"/>
+        <property           name="ssdt.clover.jar.src"
+                            value="http://ivy.ssdt.nwoca.org/repository/clover/clover.jar"/>
+        <property           name="clover.dest" value="${build.dir}/clover"/>
+        <ssdt:fetch         dest="${clover.jar.file}"
+                            src="${ssdt.clover.jar.src}"/>
+        <property           name="clover.license"
+                            value="${user.home.ant.lib}/clover.license"/>
+        <condition property="clover.installed">
+            <and>
+                <available classname="com.cenqua.clover.CloverInstr" />
+                <available file="${clover.license}"/>
+            </and>
+        </condition>
+    </target>
+
+    <target name="with.coverage" depends="init,-check.clover" if="clover.installed">
+        <taskdef resource="cloverlib.xml"/>
+    
+        <property name="coverage.run.with.clover" value="true"/>
+        <clover-env/>
+        <clover-setup recordTestResults="false"/>
+        <clover-clean/>
+        <mkdir dir="${build.dir}/.clover"/>
+        <mkdir dir="${build.dir}/clover"/>
+    </target>
+
+
+    <target name="coverage.xml" description="Generates an XML report to ${clover.dest}." if="coverage.run.with.clover">
+        <clover-report>
+            <current outfile="${clover.dest}/clover.xml" title="${ivy.project.module}" span="${clover.span}">
+                <format type="xml"/>
+                <testresults dir="build/test/results" includes="TEST-*.xml"/>
+             <sourcepath>
+                <pathelement path="${src.dir}"/>
+              </sourcepath>
+            </current>
+        </clover-report>
+    </target>
+
+
+
+</project>
--- a/sonar-ant.xml	Tue Apr 05 16:28:00 2011 -0400
+++ b/sonar-ant.xml	Thu Apr 07 19:14:15 2011 -0400
@@ -6,18 +6,20 @@
 
     <description>Sonar Ant tasks</description>
 
-    <property   name="ssdt.sonar.jar.src"         value="http://ivy.ssdt.nwoca.org/repository/sonar/sonar-ant-task.jar"/>
-
+    <property           name="ssdt.sonar.jar.src"
+                        value="http://ivy.ssdt.nwoca.org/repository/sonar/sonar-ant-task.jar"/>
     <ssdt:fetch         dest="${user.home.ant.lib}/sonar.jar"
                         src="${ssdt.sonar.jar.src}"/>
+    <ssdt:import-ant    file="clover-ant.xml"/>
 
     <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"/>
 
     <property name="sonar.host.url" value="http://localhost:9000" />
     <property name="sonar.language" value="grvy"/>
 
-
-    <target name="sonar" depends="project.init,ivy-info">
+    <target name="sonar" depends="project.init,ivy-info,coverage.xml">
+        <property name="clover.dest" value="${build.dir}/clover"/>
+        <property name="coverage.report.path" location="${clover.dest}/clover.xml"/>
         <sonar:sonar 
             workDir="${build.dir}/sonar"
             key="${ivy.project.organisation}:${ivy.project.module}"
@@ -29,6 +31,7 @@
             <property key="sonar.language" value="${sonar.language}" />
             <property key="sonar.dynamicAnalysis" value="reuseReports" />
             <property key="sonar.surefire.reportsPath" value="${build.test.results.dir}"/>
+            <property key="sonar.clover.reportPath" value="${clover.dest}/clover.xml"/>
             <tests>
                 <path location="${test.dir}" />
             </tests>