changeset 31:0cbc383e341b

TL-34: Handle case of missing coverage data file under sonar
author smith@nwoca.org
date Tue, 12 Apr 2011 16:49:39 -0400
parents 22f63ae66fed
children 9480be99ec76
files jacoco-ant.xml
diffstat 1 files changed, 22 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/jacoco-ant.xml	Mon Apr 11 20:03:18 2011 -0400
+++ b/jacoco-ant.xml	Tue Apr 12 16:49:39 2011 -0400
@@ -43,21 +43,28 @@
             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>
+        <if><available file="${jacoco.data.file}"/>
+            <then>
+                <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>
+            </then>
+            <else>
+                <echo message="Coverage data not available. coverage.xml skipped"/>
+            </else>
+        </if>
 
     </target>