changeset 27:ea29594bb799

TL-34: Switch to Jacoco for coverage analysis.
author smith@nwoca.org
date Sun, 10 Apr 2011 21:42:19 -0400
parents 639bec4999f2
children ad0a75e20f7b
files groovy-ant.xml jacoco-ant.xml sonar-ant.xml
diffstat 3 files changed, 94 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/groovy-ant.xml	Fri Apr 08 17:37:19 2011 -0400
+++ b/groovy-ant.xml	Sun Apr 10 21:42:19 2011 -0400
@@ -37,6 +37,7 @@
             <attribute default="${excludes}" name="excludes"/>
             <attribute default="**" name="testincludes"/>
             <sequential>
+                <property name="jacoco.coverage.agent" value=""/>
                 <if>
                     <isset property="java.agent.jar"/>
                     <then>
@@ -70,6 +71,7 @@
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg line="${run.jvmargs}"/>
                     <jvmarg line="${jvm.agent}"/>
+                    <jvmarg line="${jacoco.coverage.agent}"/>
                 </junit>
             </sequential>
         </macrodef>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jacoco-ant.xml	Sun Apr 10 21:42:19 2011 -0400
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="jacoco-project-tasks" default="" basedir="."
+         xmlns:ivy="antlib:fr.jayasoft.ivy.ant"
+         xmlns:ssdt="http://www.ssdt-ohio.org/ant/common"
+         xmlns:jacoco="antlib:org.jacoco.ant">
+
+    <description>jacoco Ant tasks</description>
+
+    <property name="jacoco.report.dir" value="build/jacoco"/>
+    <property name="jacoco.data.file" value="build/jacoco/jacoco.exec"/>
+
+    <target name="-check.jacoco" depends="project.init,ivy-info">
+        <property           name="jacoco.ant.jar.file"
+                            value="${user.home.ant.lib}/jacoco-ant.jar"/>
+        <property           name="jacoco.agent.jar.file"
+                            value="${ssdt.devel.kit}/jacoco-agent.jar"/>
+        <property           name="ssdt.jacoco.ant.jar.src"
+                            value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoant.jar"/>
+        <property           name="ssdt.jacoco.agent.jar.src"
+                            value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoagent.jar"/>
+        <ssdt:fetch         dest="${jacoco.ant.jar.file}"
+                            src="${ssdt.jacoco.ant.jar.src}"/>
+        <ssdt:fetch         dest="${jacoco.agent.jar.file}"
+                            src="${ssdt.jacoco.agent.jar.src}"/>
+        <property name="jacoco.installed" value="true"/>
+        <property name="jacoco.dir" value="${build.dir}/jacoco"/>
+
+    </target>
+
+    <target name="with.coverage" depends="-check.jacoco" if="jacoco.installed">
+        <property name="coverage.run.with.jacoco" value="true"/>
+        <mkdir dir="${jacoco.dir}"/>
+        <copy file="${jacoco.agent.jar.file}" tofile="${jacoco.dir}/jacocoagent.jar"/>
+        <property name="_jacoco.agentFile" value="${jacoco.dir}/jacocoagent.jar"/>
+        <taskdef  uri="antlib:org.jacoco.ant"
+                  classpath="${jacoco.ant.jar.file}"
+                  resource="org/jacoco/ant/antlib.xml"/>
+        <jacoco:agent property="jacoco.coverage.agent"
+                      destfile="${jacoco.data.file}"/>
+    </target>
+
+    <target name="coverage.xml"
+            description="Generates an XML converage report."
+            depends="-check.jacoco,project.init"
+            if="jacoco.installed">
+        <mkdir dir="${jacoco.report.dir}"/>
+        <jacoco:report>
+            <executiondata>
+                <file file="${jacoco.data.file}"/>
+            </executiondata>
+            <structure name="${ivy.project.module}">
+                <classfiles>
+                    <fileset dir="${build.classes.dir}"/>
+                </classfiles>
+                <sourcefiles encoding="UTF-8">
+                    <fileset dir="${src.dir}"/>
+                </sourcefiles>
+            </structure>
+            <xml destfile="${jacoco.report.dir}/jacoco.xml"/>
+        </jacoco:report>
+
+    </target>
+
+    <target name="coverage.html"
+            description="Generates an HTML converage report."
+            depends="-check.jacoco"
+            if="jacoco.installed">
+        <mkdir dir="${jacoco.report.dir}"/>
+        <jacoco:report>
+            <executiondata>
+                <file file="${jacoco.data.file}"/>
+            </executiondata>
+            <structure name="${ivy.project.module}">
+                <classfiles>
+                    <fileset dir="${build.classes.dir}"/>
+                </classfiles>
+                <sourcefiles encoding="UTF-8">
+                    <fileset dir="${src.dir}"/>
+                </sourcefiles>
+            </structure>
+            <html destdir="${jacoco.report.dir}"/>
+        </jacoco:report>
+    </target>
+
+</project>
--- a/sonar-ant.xml	Fri Apr 08 17:37:19 2011 -0400
+++ b/sonar-ant.xml	Sun Apr 10 21:42:19 2011 -0400
@@ -10,33 +10,29 @@
                         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://ssdt-web-10.nwoca.org:9000" />
-    <property name="sonar.language" value="grvy"/>
+    <ssdt:import-ant    file="jacoco-ant.xml"/>
 
     <target name="-check-sonar">
         <property file="${ssdt.devel.kit}/sonar.properties"/>
+        <property name="sonar.host.url" value="http://ssdt-web-10.nwoca.org:9000" />
+        <property name="sonar.language" value="grvy"/>
+        <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"/>
     </target>
 
     <target name="sonar" depends="project.init,-check-sonar,ivy-info,coverage.xml" if="sonar.enabled">
-        <property name="clover.dest" value="${build.dir}/clover"/>
-        <property name="coverage.report.path" location="${clover.dest}/clover.xml"/>
-        <sonar:sonar 
+        <sonar:sonar
             workDir="${build.dir}/sonar"
             key="${ivy.project.organisation}:${ivy.project.module}"
             version="${project.version}" >
             <sources>
                 <path location="${src.dir}" />
             </sources>
-            <property key="sonar.core.codeCoveragePlugin" value="clover"/>
+            <property key="sonar.core.codeCoveragePlugin" value="jacoco"/>
             <property key="sonar.projectName" value="${ivy.project.module}"/>
             <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"/>
+            <property key="sonar.jacoco.reportPath" value="${jacoco.data.file}"/>
             <tests>
                 <path location="${test.dir}" />
             </tests>