-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
149 lines (133 loc) · 5.17 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<project name="AntJarJCovExample">
<property name="built" value="built" />
<property name="jar.name" value="sample.jar" />
<property name="testjar.name" value="tests.jar" />
<property name="main.build.dir" value="built/main/classes" />
<property name="main.build.instrumented.dir" value="built/main/instrumented/classes" />
<property name="main.src.dir" value="src" />
<property name="test.build.dir" value="built/test/classes" />
<property name="test.src.dir" value="test" />
<property name="jcov.jar" value="lib/jcov.jar" />
<property name="jcov_network.jar" value="lib/jcov_network_saver.jar" />
<property name="jcoverage.template" value="jcoverage_template.xml" />
<property name="jcoverage.result" value="jcoverage_result.xml" />
<property name="coverage-report" value="coverage-report" />
<path id="classpath.classes">
<path refid="classpath.junit" />
<pathelement location="${built}/${jar.name}" />
<pathelement location="${built}/${testjar.name}" />
</path>
<path id="classpath.junit">
<pathelement location="lib/junit-4.12.jar" />
<pathelement location="lib/hamcrest-core-1.3.jar" />
<pathelement location="lib/jcov_network_saver.jar" />
</path>
<path id="classpath.test">
<pathelement location="${main.build.dir}" />
<path refid="classpath.junit" />
<pathelement location="lib/jcov.jar" />
<pathelement location="lib/jcov_file_saver.jar" />
<pathelement location="lib/jcov_jcard_saver.jar" />
<pathelement location="lib/jcov_me_network_saver.jar" />
<pathelement location="lib/jcov_network_saver.jar" />
<pathelement location="lib/jtobserver.jar" />
</path>
<target name="0.clean-up" description="Clean it up. All of it.">
<delete dir="${built}" />
<delete file="template.xml" />
</target>
<target name="compile">
<mkdir dir="${main.build.dir}" />
<javac srcdir="${main.src.dir}" destdir="${main.build.dir}" includeantruntime="false" />
<exec command="find ${basedir}/${main.build.dir} -name *.class -ls" />
</target>
<target name="jar" depends="compile">
<jar destfile="${built}/${jar.name}">
<fileset dir="${main.build.dir}">
<include name="**/*.class" />
</fileset>
</jar>
<exec command="jar -tvf ${built}/${jar.name}" />
<jar destfile="${built}/${testjar.name}">
<fileset dir="${test.build.dir}">
<include name="**/*.class" />
</fileset>
</jar>
<exec command="jar -tvf ${built}/${testjar.name}" />
</target>
<target name="test-compile" depends="compile">
<mkdir dir="${test.build.dir}" />
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false">
<classpath refid="classpath.test" />
</javac>
</target>
<target name="3.run-tests" description="Run the tests.">
<junit printsummary="on" haltonfailure="yes" fork="true">
<classpath>
<pathelement location="${built}/${testjar.name}/" />
<pathelement location="${built}/${jar.name}" />
<path refid="classpath.junit" />
<path refid="classpath.test" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${test.build.dir}" includes="**/*Test*.class" />
</batchtest>
</junit>
</target>
<target name="instrument-classes">
<echo message="Instrumenting classes" />
<java jar="${jcov.jar}" fork="true" failonerror="true" classpath="classpath.test">
<arg line="instr -output ${main.build.instrumented.dir} ${test.build.dir}" />
</java>
<echo message="compiled classes" />
<exec executable="find">
<arg value="${basedir}/${main.build.dir}" />
<arg value="-name" />
<arg value="*.class" />
<arg value="-ls" />
</exec>
<echo message="instrumented classes" />
<exec executable="find">
<arg value="${basedir}/${main.build.instrumented.dir}" />
<arg value="-name" />
<arg value="*.class" />
<arg value="-ls" />
</exec>
</target>
<target name="1.build-instrument-jar" description="Add jcoverage instrumentation" depends="compile, test-compile, jar">
<echo message="Instrumenting jar ${built}/${jar.name}" />
<java jar="${jcov.jar}" fork="true" failonerror="true" classpath="classpath.test">
<arg line="instr -t ${built}/${jcoverage.template} ${built}/${jar.name}" />
</java>
<echo message=" " />
<echo message="jar ${built}/${jar.name} Contents" />
<exec executable="jar">
<arg value="-tvf" />
<arg value="${built}/${jar.name}" />
</exec>
<echo message=" " />
<echo message="jcoverage template ${jcoverage.template}" />
<exec executable="find">
<arg value="${basedir}/${built}" />
<arg value="-name" />
<arg value="${jcoverage.template}" />
<arg value="-ls" />
</exec>
</target>
<target name="2.coverage-start" description="Start grabber for test data collection">
<java jar="${jcov.jar}" fork="true" classpath="">
<arg line=" grabber -t ${built}/${jcoverage.template} -o ${built}/${jcoverage.result}" />
</java>
</target>
<target name="4.coverage-stop" description="Stop Grabber. Kill it.">
<java jar="${jcov.jar}" fork="true">
<arg line=" grabberManager -kill" />
</java>
</target>
<target name="5.coverage-report" description="Generage coverage report">
<java jar="${jcov.jar}" fork="true">
<arg line=" repgen -o ${built}/${coverage-report} ${built}/${jcoverage.result}" />
</java>
</target>
</project>