-
Notifications
You must be signed in to change notification settings - Fork 83
/
build.xml
341 lines (311 loc) · 14.4 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<project name="JSCover" basedir="." default="pre-commit" xmlns:resolver="antlib:org.apache.maven.resolver.ant">
<property environment="env" />
<property file="build.properties" />
<property file="src/main/resources/jscover/configuration.properties" />
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
<fileset dir="lib" includes="maven-resolver-ant-tasks-*uber.jar"/>
</classpath>
</taskdef>
<!-- Initialize Maven task. Allows Java dependencies to be managed in pom.xml -->
<target name="mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
<resolver:localrepo dir="${user.home}/.m2/repository"/>
<resolver:pom file="pom.xml" id="pom"/>
<resolver:resolve>
<properties/>
<dependencies>
<pom refid="pom"/>
</dependencies>
<path refid="compile.classpath" classpath="compile"/>
<path refid="test.classpath" scopes="compile,runtime,test"/>
<path refid="runtime.classpath" scopes="runtime"/>
</resolver:resolve>
<taskdef classpathref="test.classpath" resource="tasks.properties" />
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="test.classpath"/>
</target>
<import file="build-maven.xml"/>
<path id="classpath-main">
<pathelement path="${classes.main.dir}" />
</path>
<path id="classpath-test">
<pathelement path="${classes.main.dir}" />
<pathelement path="${classes.test-unit.dir}" />
<pathelement path="${classes.test-integration.dir}" />
<pathelement path="${classes.test-acceptance.dir}" />
</path>
<target name="clean">
<delete dir="target" />
<delete dir=".">
<include name="jacoco-*.exec"/>
<include name="jscover.log*"/>
</delete>
</target>
<target name="init" depends="mvn-init"/>
<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="${report.jscoverage.dir}" />
<mkdir dir="${classes.main.dir}" />
<mkdir dir="${classes.test-unit.dir}" />
<mkdir dir="${classes.test-integration.dir}" />
<mkdir dir="${classes.test-acceptance.dir}" />
</target>
<target name="compile" depends="init, dirsetup">
<javac includeantruntime="false" debug="true" srcdir="${src.main.dir}" destdir="${classes.main.dir}"
classpathref="compile.classpath" source="11" target="11"/>
<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="${com.google.javascript:closure-compiler:jar}" tofile="${dist.dir}/closure-compiler.jar"/>
<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="closure-compiler.jar"/><!--Add required JARs here-->
</manifest>
</jar>
</target>
<target name="jar-all" depends="compile-acceptance-tests">
<property name="tmpDir" value="${build.dir}/tmp"/>
<mkdir dir="${tmpDir}"/>
<unzip src="${com.google.javascript:closure-compiler:jar}" dest="${tmpDir}"/>
<unzip src="${com.google.code.gson:gson:jar}" dest="${tmpDir}"/>
<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="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Main-Class" value="jscover.Main"/>
</manifest>
</jar>
<junit haltonfailure="yes" haltonerror="yes" failureProperty="test.failure" errorproperty="test.failure">
<classpath>
<path refid="classpath-test" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</classpath>
<formatter type="xml" />
<formatter type="brief" usefile="no" />
<batchtest fork="yes" todir="${report.test.dir}">
<fileset dir="${classes.test-acceptance.dir}">
<include name="**/ClassVersionChecker.class" />
</fileset>
</batchtest>
</junit>
<antcall target="report-if-failed"/>
<fail if="test.failure"/>
</target>
<target name="mvn-install-local" depends="jar-all">
<copy file="${dist.dir}/${ant.project.name}-all.jar" tofile="${maven.repo.local}/com/github/tntim96/JSCover/${version}/JSCover-${version}.jar"/>
</target>
<target name="zip">
<zip destfile="${dist.dir}/${ant.project.name}-${version}.zip">
<fileset dir="${basedir}">
<include name="History.md"/>
<include name="*.md"/>
<include name="build.*"/>
<include name="config/**"/>
<include name="data/**"/>
<include name="doc/**"/>
<include name="examples/**"/>
<include name="lib/**"/>
<include name="log.properties"/>
<include name="pom.xml"/>
<include name="src/**"/>
<include name="${dist.dir}/*.jar"/>
</fileset>
</zip>
</target>
<target name="release" depends="pre-commit, jar-test, jar-all-test, zip" description="Build sourceforge release binary"/>
<target name="coverage-report" depends="init" xmlns:jacoco="antlib:org.jacoco.ant">
<jacoco:report>
<executiondata>
<file file="jacoco-integration.exec"/>
</executiondata>
<structure name="JSCover - Integration">
<classfiles>
<fileset dir="${classes.main.dir}">
<exclude name="jscover/ExitHelper.class" />
<exclude name="**/SimpleWebServer.class" />
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.main.dir}"/>
</sourcefiles>
</structure>
<html destdir="${report.coverage.dir}"/>
<xml destfile="${report.coverage.dir}/jacoco.xml"/>
<check>
<rule element="BUNDLE">
<limit counter="LINE" value="COVEREDRATIO" minimum="0.92"/>
<limit counter="BRANCH" value="COVEREDRATIO" minimum="0.93"/>
</rule>
</check>
</jacoco:report>
</target>
<target name="coverage-report-all" depends="init" xmlns:jacoco="antlib:org.jacoco.ant">
<jacoco:merge destfile="jacoco-merged.exec">
<fileset dir=".">
<include name="jacoco-integration.exec"/>
<include name="jacoco-acceptance.exec"/>
</fileset>
</jacoco:merge>
<jacoco:report>
<executiondata>
<file file="jacoco-merged.exec"/>
</executiondata>
<structure name="JSCover - All">
<classfiles>
<fileset dir="${classes.main.dir}">
<exclude name="jscover/ExitHelper.class" />
<exclude name="**/SimpleWebServer.class" />
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.main.dir}"/>
</sourcefiles>
</structure>
<html destdir="${report.coverage.all.dir}"/>
<xml destfile="${report.coverage.all.dir}/coverage.xml"/>
<check>
<rule element="BUNDLE">
<limit counter="LINE" value="COVEREDRATIO" minimum="0.97"/>
<limit counter="BRANCH" value="COVEREDRATIO" minimum="0.95"/>
</rule>
</check>
</jacoco:report>
</target>
<target name="compile-tests" depends="compile">
<javac includeantruntime="false" debug="true" srcdir="${src.test-unit.dir}"
destdir="${classes.test-unit.dir}" source="11" target="11" encoding="UTF-8">
<classpath>
<path refid="classpath-main" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</classpath>
</javac>
<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}" source="11" target="11">
<classpath>
<path refid="classpath-test" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</classpath>
</javac>
<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}" source="11" target="11">
<classpath>
<path refid="classpath-test" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</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" xmlns:jacoco="antlib:org.jacoco.ant">
<property name="tests" value="*Test" />
<delete dir="${report.test.dir}" />
<mkdir dir="${report.test.dir}" />
<jacoco:coverage destfile="jacoco-integration.exec" includes="jscover.*" excludes="*.ExitHelper:*.*Test">
<junit fork="true" forkmode="perBatch" haltonfailure="no" haltonerror="no" failureProperty="test.failure" errorproperty="test.failure">
<jvmarg value="-ea"/>
<classpath>
<path refid="classpath-test" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</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>
</jacoco:coverage>
<antcall target="report-if-failed"/>
<fail if="test.failure"/>
</target>
<target name="run-acceptance-tests" depends="compile-acceptance-tests" xmlns:jacoco="antlib:org.jacoco.ant">
<property name="tests" value="*Test" />
<jacoco:coverage destfile="jacoco-acceptance.exec" includes="jscover.*" excludes="*.ExitHelper:*.*Test">
<junit fork="true" forkmode="perTest" haltonfailure="no" haltonerror="no" failureProperty="test.failure" errorproperty="test.failure">
<jvmarg value="-ea"/>
<classpath>
<path refid="classpath-test" />
<path refid="compile.classpath" />
<path refid="test.classpath" />
</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>
</jacoco:coverage>
<antcall target="report-if-failed"/>
<fail if="test.failure"/>
</target>
<target name="jar-test" depends="jar">
<java jar="${dist.dir}/${ant.project.name}.jar" fork="true" spawn="true">
<arg line="-ws --port=9080"/>
</java>
<waitfor maxwait="5" maxwaitunit="second" checkevery="100" checkeveryunit="millisecond" timeoutproperty="failed">
<http url="http://localhost:9080/jscoverage.html"/>
</waitfor>
<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}/${ant.project.name}-all.jar" fork="true" spawn="true">
<arg line="-ws --port=9080"/>
</java>
<waitfor maxwait="5" maxwaitunit="second" checkevery="100" checkeveryunit="millisecond" timeoutproperty="failed">
<http url="http://localhost:9080/jscoverage.html"/>
</waitfor>
<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"/>
<target name="pre-commit" depends="clean, junit, run-acceptance-tests, junit-report, coverage-report-all" description="Run this before committing"/>
</project>