forked from tntim96/JSCover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
250 lines (222 loc) · 9.67 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<project name="JSCover" basedir="." default="pre-commit">
<property environment="env" />
<property file="build.properties" />
<property file="src/main/resources/jscover/configuration.properties" />
<path id="classpath-main">
<pathelement path="${classes.main.dir}" />
<pathelement path="${classes.test-unit.dir}" />
<pathelement path="${classes.test-integration.dir}" />
<pathelement path="${classes.test-acceptance.dir}" />
<fileset dir="${lib.build.dir}" includes="**/*.jar" />
<fileset dir="${lib.run.dir}" includes="*.jar" />
</path>
<path id="classpath-cobertura">
<pathelement path="${classes.instrumented.dir}" />
<pathelement path="${classes.main.dir}" />
<pathelement path="${classes.test-unit.dir}" />
<pathelement path="${classes.test-integration.dir}" />
<pathelement path="${classes.test-acceptance.dir}" />
<fileset dir="${lib.build.dir}" includes="**/*.jar" />
<fileset dir="${lib.run.dir}" includes="*.jar" />
</path>
<path id="classpath-htmlunit">
<fileset dir="${html.unit.dir}/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean">
<delete dir="target" />
<delete file="cobertura.ser" />
</target>
<target name="dirsetup">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dir}/reports" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${report.test.dir}" />
<mkdir dir="${report.spec.dir}" />
<mkdir dir="${report.checkstyle.dir}" />
<mkdir dir="${report.coverage.dir}" />
<mkdir dir="${report.coverage.all.dir}" />
<mkdir dir="${classes.main.dir}" />
<mkdir dir="${classes.instrumented.dir}" />
<mkdir dir="${classes.test-unit.dir}" />
<mkdir dir="${classes.test-integration.dir}" />
<mkdir dir="${classes.test-acceptance.dir}" />
</target>
<target name="compile" depends="dirsetup">
<javac includeantruntime="false" debug="true" srcdir="${src.main.dir}" destdir="${classes.main.dir}" classpathref="classpath-main" />
<copy todir="${classes.main.dir}" includeemptydirs="no">
<fileset dir="${src.resources.dir}" />
</copy>
</target>
<target name="stop-server">
<get src="http://localhost:8080/stop" dest="${build.dir}/stop.txt" verbose="true"/>
</target>
<target name="jar" depends="compile">
<copy file="lib/runtime/js.jar" todir="${dist.dir}"/>
<jar jarfile="${dist.dir}/${ant.project.name}.jar"
basedir="${classes.main.dir}"
compress="true">
<manifest>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Main-Class" value="jscover.Main"/>
<attribute name="Class-Path" value="commons-io-1.4.jar commons-lang-2.4.jar js.jar"/>
</manifest>
</jar>
</target>
<target name="jar-all" depends="compile">
<property name="tmpDir" value="${build.dir}/tmp"/>
<mkdir dir="${tmpDir}"/>
<unzip src="lib/runtime/js.jar" dest="${tmpDir}"/>
<move file="${tmpDir}/LICENSE.txt" tofile="${tmpDir}/META-INF/LICENSE-mozilla.txt"/>
<copy todir="${tmpDir}" includeemptydirs="no">
<fileset dir="${classes.main.dir}" />
</copy>
<jar jarfile="${dist.dir}/${ant.project.name}-all.jar"
basedir="${tmpDir}"
compress="true">
<manifest>
<attribute name="Implementation-Title" value="JSCover"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Main-Class" value="jscover.Main"/>
</manifest>
</jar>
</target>
<target name="zip" depends="pre-commit, jar-test, jar-all-test">
<zip destfile="${dist.dir}/${ant.project.name}-${version}.zip">
<fileset dir="${basedir}">
<include name="**/*"/>
<exclude name=".*/**"/>
<exclude name="bin/**"/>
<exclude name="${build.dir}/**"/>
</fileset>
<fileset dir="${basedir}">
<include name="${dist.dir}/*.jar"/>
</fileset>
</zip>
</target>
<taskdef classpathref="classpath-cobertura" resource="tasks.properties" />
<target name="cobertura-setup" depends="compile">
<delete file="cobertura.ser" failonerror="false" />
<cobertura-instrument todir="${classes.instrumented.dir}">
<ignore regex="org.apache.log4j.*" />
<fileset dir="${classes.main.dir}">
<include name="**/*.class" />
<exclude name="**/FileSystemInstrumenter.class" /><!-- Todo add this back in with tests -->
<exclude name="**/WebServer.class" />
<exclude name="**/NanoHTTPD*.class" />
</fileset>
<classpath>
<path refid="classpath-cobertura" />
</classpath>
</cobertura-instrument>
<copy todir="${classes.instrumented.dir}" includeemptydirs="no">
<fileset dir="${src.resources.dir}" />
<fileset dir="${src.test-integration.resources.dir}" />
</copy>
</target>
<target name="coverage-report">
<cobertura-report format="html" destdir="${report.coverage.dir}" srcdir="${src.main.dir}" />
</target>
<target name="coverage-report-all">
<cobertura-report format="html" destdir="${report.coverage.all.dir}" srcdir="${src.main.dir}" />
</target>
<target name="coverage-check">
<cobertura-check totallinerate="83" totalbranchrate="83"/>
</target>
<target name="coverage-check-all">
<cobertura-check totallinerate="94" totalbranchrate="89"/>
</target>
<target name="compile-tests" depends="compile">
<javac includeantruntime="false" debug="true" srcdir="${src.test-unit.dir}"
destdir="${classes.test-unit.dir}" classpathref="classpath-main" />
<copy todir="${classes.test-unit.dir}" includeemptydirs="no">
<fileset dir="${src.test-resources.dir}" />
</copy>
</target>
<target name="compile-integration-tests" depends="compile-tests">
<javac includeantruntime="false" debug="true" srcdir="${src.test-integration.dir}"
destdir="${classes.test-integration.dir}" classpathref="classpath-main" />
<copy todir="${classes.test-integration.dir}" includeemptydirs="no">
<fileset dir="${src.test-integration.resources.dir}" />
</copy>
</target>
<target name="compile-acceptance-tests" depends="compile-integration-tests">
<javac includeantruntime="false" debug="true" srcdir="${src.test-acceptance.dir}"
destdir="${classes.test-acceptance.dir}">
<classpath>
<path refid="classpath-main" />
<path refid="classpath-htmlunit" />
</classpath>
</javac>
<copy todir="${classes.test-acceptance.dir}" includeemptydirs="no">
<fileset dir="${src.test-acceptance.resources.dir}" />
</copy>
</target>
<target name="run-tests" depends="compile-integration-tests, cobertura-setup">
<property name="tests" value="*Test" />
<delete dir="${report.test.dir}" />
<mkdir dir="${report.test.dir}" />
<junit forkmode="perBatch" haltonfailure="no" haltonerror="no" failureProperty="test.failure" errorproperty="test.failure">
<classpath>
<path refid="classpath-cobertura" />
</classpath>
<formatter type="xml" />
<formatter type="brief" usefile="no" />
<batchtest fork="yes" todir="${report.test.dir}">
<fileset dir="${classes.test-unit.dir}">
<include name="**/${tests}.class" />
</fileset>
<fileset dir="${classes.test-integration.dir}">
<include name="**/${tests}.class" />
</fileset>
</batchtest>
</junit>
<antcall target="report-if-failed"/>
<fail if="test.failure"/>
</target>
<target name="run-acceptance-tests" depends="compile-acceptance-tests">
<property name="tests" value="*Test" />
<junit forkmode="perTest" haltonfailure="no" haltonerror="no" failureProperty="test.failure" errorproperty="test.failure">
<classpath>
<path refid="classpath-cobertura" />
<path refid="classpath-htmlunit" />
</classpath>
<formatter type="xml" />
<formatter type="brief" usefile="no" />
<batchtest fork="yes" todir="${report.test.dir}">
<fileset dir="${classes.test-acceptance.dir}">
<include name="**/${tests}.class" />
</fileset>
</batchtest>
</junit>
<antcall target="report-if-failed"/>
<fail if="test.failure"/>
</target>
<target name="jar-test" depends="jar">
<java jar="${dist.dir}/JSCover.jar" fork="true" spawn="true">
<arg line="-ws --port=9080"/>
</java>
<get maxtime="2" src="http://localhost:9080/stop" dest="${build.dir}/stop.txt"/>
</target>
<target name="jar-all-test" depends="jar-all">
<java jar="${dist.dir}/JSCover-all.jar" fork="true" spawn="true">
<arg line="-ws --port=9080"/>
</java>
<get maxtime="2" src="http://localhost:9080/stop" dest="${build.dir}/stop.txt"/>
</target>
<target name="report-if-failed" if="test.failure">
<antcall target="junit-report"/>
</target>
<target name="junit-report">
<junitreport todir="${report.test.dir}">
<fileset dir="${report.test.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.test.dir}" />
</junitreport>
</target>
<target name="junit" depends="run-tests, coverage-report, coverage-check"/>
<target name="pre-commit" depends="clean, junit, run-acceptance-tests, junit-report, coverage-report-all, coverage-check-all" description="Run this before committing"/>
</project>