forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
516 lines (439 loc) · 19.9 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<!--
Copyright (c) 2007 Mockito contributors
This program is made available under the terms of the MIT License.
-->
<project name="mockito" basedir="." default="all">
<loadproperties srcfile="version.properties" />
<property name="src.dir" value="src" />
<property name="test.src.dir" value="test" />
<property name="target.dir" value="target" />
<property name="snapshots" value="${target.dir}/snapshots" />
<property name="src.classes.dir" value="${target.dir}/classes" />
<property name="test.classes.dir" value="${target.dir}/test-classes" />
<property name="test.reports.dir" value="${target.dir}/reports/junit" />
<property name="test.reports.dir.html" value="${target.dir}/reports/junit.html" />
<property name="pmd.reports.dir" value="${target.dir}/reports/pmd" />
<property name="javadoc.dir" value="${target.dir}/javadoc" />
<property name="lib.dir" value="lib" />
<property name="lib.dir.build" value="lib/build" />
<property name="lib.dir.run" value="lib/run" />
<property name="lib.dir.compile" value="lib/compile" />
<property name="lib.dir.test" value="lib/test" />
<property name="lib.dir.repackaged" value="lib/repackaged" />
<property name="lib.dir.sources" value="lib/sources" />
<property name="jar.core" value="mockito-core-${version}.jar" />
<property name="jar.core.javadoc" value="mockito-core-${version}-javadoc.jar" />
<property name="jar.core.sources" value="mockito-core-${version}-sources.jar" />
<property name="jar.all" value="mockito-all-${version}.jar" />
<property name="jar.all.javadoc" value="mockito-all-${version}-javadoc.jar" />
<property name="jar.all.sources" value="mockito-all-${version}-sources.jar" />
<property name="jar.core.osgified" value="${jar.core}-osgified" />
<property name="jar.all.osgified" value="${jar.all}-osgified" />
<property name="jar.tests" value="mockito-tests.jar" />
<property name="zip" value="mockito-${version}.zip" />
<property name="maven.repository.dir" value="${basedir}/maven/repository" />
<path id="compile.classpath">
<fileset dir="${lib.dir.run}" includes="*.jar" />
<fileset dir="${lib.dir.compile}" includes="*.jar" />
<fileset dir="${lib.dir.repackaged}" includes="*.jar" />
</path>
<path id="test.compile.classpath">
<fileset dir="${lib.dir.test}" includes="*.jar" />
<path refid="compile.classpath" />
<pathelement location="${src.classes.dir}" />
</path>
<path id="test.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${test.classes.dir}" />
</path>
<path id="ant.classpath">
<fileset dir="${lib.dir.build}" includes="*.jar" />
</path>
<target name="prepare">
<mkdir dir="${src.classes.dir}" />
<mkdir dir="${test.classes.dir}" />
<mkdir dir="${test.reports.dir}" />
</target>
<target name="clean" description="Cleans out the build directories">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${target.dir}">
<exclude name="eclipse-*/**" />
</fileset>
</delete>
</target>
<target name="compile" depends="clean, prepare">
<javac srcdir="src" destdir="${src.classes.dir}" source="1.5" target="1.5" debug="true" deprecation="true" nowarn="true">
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="compile.test" depends="compile">
<javac srcdir="test" destdir="${test.classes.dir}" source="1.5" target="1.5" debug="true" deprecation="true" nowarn="true">
<classpath refid="test.compile.classpath" />
</javac>
</target>
<target name="test" depends="compile.test, pmd" description="Executes the unit tests">
<junit fork="true" forkmode="once" printsummary="on" haltonfailure="false" failureproperty="mockito.tests.failed">
<formatter type="xml"/>
<classpath refid="test.classpath" />
<jvmarg value="-ea" />
<batchtest todir="${test.reports.dir}">
<fileset dir="${test.classes.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
<antcall target="junit.report" />
<fail if="mockito.tests.failed" message="Tests failed."/>
</target>
<target name="junit.report">
<mkdir dir="${test.reports.dir.html}" />
<junitreport todir="${test.reports.dir.html}">
<fileset dir="${test.reports.dir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${test.reports.dir.html}"/>
</junitreport>
</target>
<target name="pmd" depends="prepare">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="ant.classpath" />
<mkdir dir="${pmd.reports.dir}" />
<pmd shortFilenames="true" failonruleviolation="true" rulesetfiles="conf/pmd-rules.xml">
<ruleset>Mockito</ruleset>
<formatter type="text" toConsole="true" />
<formatter type="xml" tofile="${pmd.reports.dir}/pmd_report.xml" />
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${test.src.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
<target name="jar.all" depends="test">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="ant.classpath" />
<jarjar jarfile="${target.dir}/${jar.all}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="." file="LICENSE" />
<fileset dir="." file="NOTICE" />
<fileset dir="${src.classes.dir}" />
<zipfileset dir="${src.dir}" />
<fileset dir="${lib.dir.run}" excludes="*.jar" />
<fileset dir="${lib.dir.repackaged}" excludes="*.jar" />
<zipfileset src="${lib.dir.run}/com.springsource.org.objenesis-1.0.0.jar">
<exclude name="META-INF/maven/**"/>
</zipfileset>
<zipfileset src="${lib.dir.run}/com.springsource.org.hamcrest.core-1.1.0.jar">
<exclude name="LICENSE.txt" />
</zipfileset>
<zipfileset src="${lib.dir.repackaged}/cglib-and-asm-1.0.jar" />
</jarjar>
</target>
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="ant.classpath"/>
<target name="bnd-core" depends="jar" >
<bnd
classpath="${target.dir}/${jar.core}"
eclipse="false"
failok="false"
exceptions="true"
sourcepath="${src.dir}"
destfile="${target.dir}/${jar.core.osgified}"
files="conf/mockito-core.bnd"/>
</target>
<target name="bnd-all" depends="jar" >
<bnd
classpath="${target.dir}/${jar.all}"
eclipse="false"
failok="false"
exceptions="true"
sourcepath="${src.dir}"
destfile="${target.dir}/${jar.all.osgified}"
files="conf/mockito-all.bnd"/>
</target>
<target name="osgify.manifests" depends="bnd-core, bnd-all">
<zip update="true" destfile="${target.dir}/${jar.core}" >
<zipfileset src="${target.dir}/${jar.core.osgified}" >
<include name="META-INF/MANIFEST.MF"/>
</zipfileset>
</zip>
<zip update="true" destfile="${target.dir}/${jar.all}">
<zipfileset src="${target.dir}/${jar.all.osgified}" >
<include name="META-INF/MANIFEST.MF"/>
</zipfileset>
</zip>
<zip update="true" destfile="${target.dir}/${jar.core.sources}">
<zipfileset src="${target.dir}/${jar.core.osgified}" >
<include name="META-INF/MANIFEST.MF"/>
</zipfileset>
</zip>
<zip update="true" destfile="${target.dir}/${jar.all.sources}">
<zipfileset src="${target.dir}/${jar.all.osgified}" >
<include name="META-INF/MANIFEST.MF"/>
</zipfileset>
</zip>
<delete file="${target.dir}/${jar.all.osgified}" />
<delete file="${target.dir}/${jar.core.osgified}" />
</target>
<target name="jar" depends="jar.all">
<jarjar jarfile="${target.dir}/${jar.core}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="${lib.dir.repackaged}" includes="*.txt" />
<fileset dir="." file="LICENSE" />
<fileset dir="." file="NOTICE" />
<fileset dir="${src.classes.dir}" />
<fileset dir="${src.dir}" />
<zipfileset src="${lib.dir.repackaged}/cglib-and-asm-1.0.jar"/>
</jarjar>
</target>
<target name="sources" >
<jar jarfile="${target.dir}/${jar.core.sources}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="." file="LICENSE" />
<fileset dir="." file="NOTICE" />
<fileset dir="${src.dir}" />
<zipfileset src="${lib.dir.sources}/cglib-and-asm-1.0-sources.jar" />
</jar>
</target>
<target name="javadoc.jar" depends="javadoc">
<jar jarfile="${target.dir}/${jar.core.javadoc}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="${javadoc.dir}" />
</jar>
</target>
<target name="sources-all" depends="sources" >
<jar jarfile="${target.dir}/${jar.all.sources}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="." file="LICENSE" />
<fileset dir="." file="NOTICE" />
<fileset dir="${lib.dir.run}" >
<include name="hamcrest-license*"/>
<include name="objenesis-license*"/>
</fileset>
<fileset dir="${src.dir}" />
<zipfileset src="${lib.dir.sources}/cglib-and-asm-1.0-sources.jar" />
<zipfileset src="${lib.dir.sources}/com.springsource.org.hamcrest.core-1.1.0-sources.jar" >
<exclude name="LICENSE.txt" />
</zipfileset>
<zipfileset src="${lib.dir.sources}/com.springsource.org.objenesis-1.0.0-sources.jar" />
</jar>
</target>
<target name="javadoc-all.jar" depends="javadoc">
<jar jarfile="${target.dir}/${jar.all.javadoc}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="${javadoc.dir}" />
</jar>
</target>
<target name="prepare.package" depends="jar, javadoc, javadoc.jar, javadoc-all.jar, sources-all, osgify.manifests">
<mkdir dir="${target.dir}/mockito.zip.tmp/separate-jars" />
<copy todir="${target.dir}/mockito.zip.tmp/separate-jars">
<fileset dir="${lib.dir.run}" />
<fileset dir="${lib.dir.repackaged}" includes="*.txt" />
<fileset dir="${target.dir}" includes="${jar.core}" />
</copy>
<mkdir dir="${target.dir}/mockito.zip.tmp/javadoc" />
<copy todir="${target.dir}/mockito.zip.tmp/javadoc">
<fileset dir="${javadoc.dir}" />
</copy>
<copy todir="${target.dir}/mockito.zip.tmp">
<fileset dir="." includes="LICENSE" />
<fileset dir="." includes="NOTICE" />
<fileset dir="doc" includes="jars-info.txt" />
<fileset dir="${target.dir}" includes="${jar.all}" />
</copy>
<mkdir dir="${target.dir}/mockito.zip.tmp/sources" />
<copy todir="${target.dir}/mockito.zip.tmp/sources">
<fileset dir="${target.dir}" includes="*-sources.jar" />
</copy>
</target>
<target name="zip" depends="prepare.package">
<zip destfile="${target.dir}/${zip}">
<fileset dir="${target.dir}/mockito.zip.tmp"/>
</zip>
</target>
<target name="javadoc">
<javadoc
sourcepath="${src.dir}"
destdir="${javadoc.dir}"
stylesheetfile="javadoc/stylesheet.css"
header=""
author="true"
version="true"
use="true"
windowtitle="Mockito ${version} API">
<doctitle>
<![CDATA[
<h1><a href="org/mockito/Mockito.html">Click to see examples</a>. Mockito ${version} API.</h1>
]]>
</doctitle>
<header>
<![CDATA[
<!-- Note there is a weird javadoc task bug if using the double quote char \" that causes an 'illegal package name' error -->
<!-- using the beautify plugin for jQuery from https://bitbucket.org/larscorneliussen/beautyofcode/ -->
<script type="text/javascript">
var shBaseURL = '{@docRoot}/js/sh-2.1.382/';
</script>
<script type="text/javascript" src="{@docRoot}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="{@docRoot}/js/jquery.beautyOfCode-min.js"></script>
<script type="text/javascript">
/* Apply beautification of code */
var usingOldIE = false;
if($.browser.msie && parseInt($.browser.version) < 9) usingOldIE = true;
if(!usingOldIE) {
$.beautyOfCode.init({
theme : 'Eclipse',
brushes: ['Java']
});
var version = ${version};
/* Add name & version to header */
$(function() {
$('td.NavBarCell1[colspan=2]').each(function(index, element) {
var jqueryTD = $(element);
jqueryTD.after(
$('<td><em><strong>Mockito ${version} API</strong></em></td>').attr('class','NavBarCell1').attr('id','mockito-version-header')
);
jqueryTD.removeAttr('colspan');
})
})
}
</script>
]]>
</header>
<group title="Main package" packages="org.mockito"/>
<classpath refid="compile.classpath" />
</javadoc>
<copy todir="${javadoc.dir}/org/mockito" file="javadoc/img/logo.jpg" />
<copy todir="${javadoc.dir}/js" file="javadoc/js/jquery-1.7.min.js" />
<copy todir="${javadoc.dir}/js" file="javadoc/js/jquery.beautyOfCode-min.js" />
<copy todir="${javadoc.dir}/js/sh-2.1.382">
<fileset dir="javadoc/js/sh-2.1.382"/>
</copy>
</target>
<target name="repackage-tests" depends="compile.test">
<jar jarfile="${target.dir}/${jar.tests}">
<fileset dir="${test.classes.dir}"/>
</jar>
</target>
<target name="test.zip.release" depends="zip, repackage-tests" >
<delete dir="${target.dir}/tmp"/>
<unzip dest="${target.dir}/tmp" src="${target.dir}/${zip}" />
<junit fork="true" forkmode="once" haltonfailure="true">
<formatter type="plain" usefile="false"/>
<classpath>
<fileset dir="${target.dir}/tmp" includes="${jar.all}" />
<fileset dir="${lib.dir.test}" includes="*.jar" />
<fileset dir="${lib.dir.compile}" includes="*junit*.jar" />
<pathelement location="${target.dir}/${jar.tests}"/>
</classpath>
<jvmarg value="-ea" />
<batchtest>
<fileset dir="${test.classes.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
<target name="test.zip.release.separate.jars" depends="zip, repackage-tests" >
<delete dir="${target.dir}/tmp2"/>
<unzip dest="${target.dir}/tmp2" src="${target.dir}/${zip}" />
<junit fork="true" forkmode="once" haltonfailure="true">
<formatter type="plain" usefile="false" />
<classpath>
<fileset dir="${target.dir}/tmp2/separate-jars" includes="*.jar" />
<fileset dir="${lib.dir.test}" includes="*.jar" />
<fileset dir="${lib.dir.compile}" includes="*junit*.jar" />
<pathelement location="${target.dir}/${jar.tests}"/>
</classpath>
<jvmarg value="-ea" />
<batchtest>
<fileset dir="${test.classes.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
<target name="release.javadoc" depends="javadoc" description="releases javadoc to 'javadoc' folder" >
<copy todir="javadoc">
<fileset dir="${target.dir}/javadoc" />
</copy>
</target>
<target name="check.binaries">
<condition property="mockito.jars.exist">
<and>
<available file="${target.dir}/${jar.all}"/>
<available file="${target.dir}/${jar.all.javadoc}"/>
<available file="${target.dir}/${jar.all.sources}"/>
<available file="${target.dir}/${jar.core}"/>
<available file="${target.dir}/${jar.core.javadoc}"/>
<available file="${target.dir}/${jar.core.sources}"/>
</and>
</condition>
<fail unless="mockito.jars.exist" message="Mockito binaries don't exist. Issue ant at the command line to build."/>
</target>
<target name="copy.maven.metadata" depends="check.binaries" >
<delete dir="${maven.repository.dir}"/>
<mkdir dir="${maven.repository.dir}/org/mockito/mockito-all" />
<get src="http://search.maven.org/remotecontent?filepath=org/mockito/mockito-all/maven-metadata.xml"
dest="${maven.repository.dir}/org/mockito/mockito-all/maven-metadata.xml"/>
<mkdir dir="${maven.repository.dir}/org/mockito/mockito-core" />
<get src="http://search.maven.org/remotecontent?filepath=org/mockito/mockito-core/maven-metadata.xml"
dest="${maven.repository.dir}/org/mockito/mockito-core/maven-metadata.xml"/>
</target>
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml" classpathref="ant.classpath"/>
<target name="prepare.poms" >
<filter token="version" value="${version}"/>
<copy todir="${target.dir}" filtering="true">
<fileset dir="maven" includes="mockito-*.pom"/>
</copy>
</target>
<target name="install.artifact" depends="check.binaries, prepare.poms" description="Installs maven artifact in local repo. Helpful for testing">
<install file="${target.dir}/${jar.all}">
<pom file="${target.dir}/mockito-all.pom" />
</install>
</target>
<target name="release.maven" depends="copy.maven.metadata, prepare.poms" description="deploy binaries to sync with maven repository" >
<remoteRepository id="repo.local" url="file:///${maven.repository.dir}" />
<deploy file="${target.dir}/${jar.all}">
<pom file="${target.dir}/mockito-all.pom" />
<attach file="${target.dir}/${jar.all.javadoc}" classifier="javadoc" />
<attach file="${target.dir}/${jar.all.sources}" classifier="sources" />
<remoterepository refid="repo.local" />
</deploy>
<deploy file="${target.dir}/${jar.core}" >
<pom file="${target.dir}/mockito-core.pom" />
<attach file="${target.dir}/${jar.core.javadoc}" classifier="javadoc" />
<attach file="${target.dir}/${jar.core.sources}" classifier="sources" />
<remoterepository refid="repo.local" />
</deploy>
</target>
<target name="deploy.snapshot" depends="release.maven, deploy.snapshot.hg" />
<target name="deploy.snapshot.hg" >
<taskdef resource="net/sourceforge/ant4hg/taskdefs/antlib.xml" classpathref="ant.classpath" />
<loadproperties srcfile="../../mockito.hudson.pwd" />
<mkdir dir="${snapshots}" />
<hg cmd="clone" source="https://mockito.hudson:${mockito.hudson.pwd}@snapshots.mockito.googlecode.com/hg/"
destination="${snapshots}" />
<hg cmd="remove" dir="${snapshots}/org/mockito/mockito-core/${version}" force="true" />
<hg cmd="remove" dir="${snapshots}/org/mockito/mockito-all/${version}" force="true" />
<copy todir="${snapshots}">
<fileset dir="maven/repository" includes="**/*" />
</copy>
<hg cmd="add" dir="${snapshots}" />
<hg cmd="commit" dir="${snapshots}" message="${user.name} deployed new snapshot to please maven fan-boys and give new features to the community!" />
<hg cmd="push" dir="${snapshots}" />
</target>
<target name="test.release" depends="test.zip.release, test.zip.release.separate.jars" description="builds zip, unzips it and runs tests against jars" />
<target name="all" depends="zip" description="cleans, builds, tests, jars, zips, bundles maven" />
<target name="build.and.deploy.snapshot" depends="test, prepare.package, deploy.snapshot" />
<target name="hudson.build" depends="test, prepare.package" />
</project>