Mercurial > public > develkit
annotate jacoco-ant.xml @ 42:f1144aa0c01b
CM-127: Improve sonar target to handle java projects and optionally use 'build breaker' to fail builds
author | smith@nwoca.org |
---|---|
date | Tue, 07 Jun 2011 21:44:14 -0400 |
parents | 139a3611ae99 |
children | c1619b87800e |
rev | line source |
---|---|
27 | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <project name="jacoco-project-tasks" default="" basedir="." | |
3 xmlns:ivy="antlib:fr.jayasoft.ivy.ant" | |
4 xmlns:ssdt="http://www.ssdt-ohio.org/ant/common" | |
5 xmlns:jacoco="antlib:org.jacoco.ant"> | |
6 | |
7 <description>jacoco Ant tasks</description> | |
8 | |
9 <property name="jacoco.report.dir" value="build/jacoco"/> | |
10 <property name="jacoco.data.file" value="build/jacoco/jacoco.exec"/> | |
11 | |
12 <target name="-check.jacoco" depends="project.init,ivy-info"> | |
13 <property name="jacoco.ant.jar.file" | |
14 value="${user.home.ant.lib}/jacoco-ant.jar"/> | |
15 <property name="jacoco.agent.jar.file" | |
16 value="${ssdt.devel.kit}/jacoco-agent.jar"/> | |
17 <property name="ssdt.jacoco.ant.jar.src" | |
18 value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoant.jar"/> | |
19 <property name="ssdt.jacoco.agent.jar.src" | |
20 value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoagent.jar"/> | |
21 <ssdt:fetch dest="${jacoco.ant.jar.file}" | |
22 src="${ssdt.jacoco.ant.jar.src}"/> | |
23 <ssdt:fetch dest="${jacoco.agent.jar.file}" | |
24 src="${ssdt.jacoco.agent.jar.src}"/> | |
25 <property name="jacoco.installed" value="true"/> | |
26 <property name="jacoco.dir" value="${build.dir}/jacoco"/> | |
27 | |
28 </target> | |
29 | |
30 <target name="with.coverage" depends="-check.jacoco" if="jacoco.installed"> | |
31 <property name="coverage.run.with.jacoco" value="true"/> | |
32 <mkdir dir="${jacoco.dir}"/> | |
33 <copy file="${jacoco.agent.jar.file}" tofile="${jacoco.dir}/jacocoagent.jar"/> | |
34 <property name="_jacoco.agentFile" value="${jacoco.dir}/jacocoagent.jar"/> | |
35 <taskdef uri="antlib:org.jacoco.ant" | |
36 classpath="${jacoco.ant.jar.file}" | |
37 resource="org/jacoco/ant/antlib.xml"/> | |
38 <jacoco:agent property="jacoco.coverage.agent" | |
39 destfile="${jacoco.data.file}"/> | |
41
139a3611ae99
CM-127: Move castor-ant to develkit and teach jacoco how to instrument non-groovy projects.
smith@nwoca.org
parents:
31
diff
changeset
|
40 <var name="runmain.jvmargs.jacoco" value="${runmain.jvmargs}"/> |
139a3611ae99
CM-127: Move castor-ant to develkit and teach jacoco how to instrument non-groovy projects.
smith@nwoca.org
parents:
31
diff
changeset
|
41 <var name="runmain.jvmargs" value="${jacoco.coverage.agent} ${runmain.jvmargs.jacoco}"/> |
139a3611ae99
CM-127: Move castor-ant to develkit and teach jacoco how to instrument non-groovy projects.
smith@nwoca.org
parents:
31
diff
changeset
|
42 <echoproperties prefix="jacoco"/> |
139a3611ae99
CM-127: Move castor-ant to develkit and teach jacoco how to instrument non-groovy projects.
smith@nwoca.org
parents:
31
diff
changeset
|
43 <echoproperties prefix="runmain"/> |
27 | 44 </target> |
45 | |
46 <target name="coverage.xml" | |
47 description="Generates an XML converage report." | |
48 depends="-check.jacoco,project.init" | |
49 if="jacoco.installed"> | |
31
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
50 <if><available file="${jacoco.data.file}"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
51 <then> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
52 <mkdir dir="${jacoco.report.dir}"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
53 <jacoco:report> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
54 <executiondata> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
55 <file file="${jacoco.data.file}"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
56 </executiondata> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
57 <structure name="${ivy.project.module}"> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
58 <classfiles> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
59 <fileset dir="${build.classes.dir}"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
60 </classfiles> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
61 <sourcefiles encoding="UTF-8"> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
62 <fileset dir="${src.dir}"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
63 </sourcefiles> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
64 </structure> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
65 <xml destfile="${jacoco.report.dir}/jacoco.xml"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
66 </jacoco:report> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
67 </then> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
68 <else> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
69 <echo message="Coverage data not available. coverage.xml skipped"/> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
70 </else> |
0cbc383e341b
TL-34: Handle case of missing coverage data file under sonar
smith@nwoca.org
parents:
27
diff
changeset
|
71 </if> |
27 | 72 |
73 </target> | |
74 | |
75 <target name="coverage.html" | |
76 description="Generates an HTML converage report." | |
77 depends="-check.jacoco" | |
78 if="jacoco.installed"> | |
79 <mkdir dir="${jacoco.report.dir}"/> | |
80 <jacoco:report> | |
81 <executiondata> | |
82 <file file="${jacoco.data.file}"/> | |
83 </executiondata> | |
84 <structure name="${ivy.project.module}"> | |
85 <classfiles> | |
86 <fileset dir="${build.classes.dir}"/> | |
87 </classfiles> | |
88 <sourcefiles encoding="UTF-8"> | |
89 <fileset dir="${src.dir}"/> | |
90 </sourcefiles> | |
91 </structure> | |
92 <html destdir="${jacoco.report.dir}"/> | |
93 </jacoco:report> | |
94 </target> | |
95 | |
96 </project> |