forked from junit-team/junit4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
379 lines (336 loc) · 12.6 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
<project name="junit" default="dist" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<tstamp />
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<property file="${user.home}/.junit.properties" />
<property name="src" value="src/main/java" />
<property name="target" location="target" />
<property name="bin" location="${target}/main" />
<property name="version-base" value="4.12" />
<property name="version-status" value="-SNAPSHOT" />
<property name="version" value="${version-base}${version-status}" />
<property name="dist" value="junit${version}" />
<property name="versionfile" value="${src}/junit/runner/Version.java" />
<property name="zipfile" value="${dist}/${dist}.zip" />
<property name="testsrc" location="src/test/java" />
<property name="testbin" location="${target}/test/java" />
<property name="unjarred"
value="**/*.jar, ${testfiles}, doc/**, README.md, .classpath, .project, epl-v10.html" />
<property name="binjar" value="junit-${version}.jar" />
<property name="srcjar" value="junit-${version}-src.jar" />
<property name="docjar" value="junit-${version}-javadoc.jar" />
<property name="depjar" value="junit-dep-${version}.jar" />
<property name="depsrcjar" value="junit-dep-${version}-src.jar" />
<property name="depdocjar" value="junit-dep-${version}-javadoc.jar" />
<property name="javadocdir" location="${dist}/javadoc" />
<property name="javadoczip" location="${dist}-javadoc.zip" />
<property name="hamcrestlib" location="lib/hamcrest-core-1.3.jar" />
<property name="hamcrestlibsources" location="lib/hamcrest-core-1.3-sources.jar" />
<property name="hamcrestsrc" location="${dist}/temp.hamcrest.source" />
<property name="maven.deploy.goal" value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
<target name="init">
<tstamp/>
</target>
<target name="versiontag" depends="init">
<filter token="version" value="${version}" />
<copy
file="${versionfile}.template"
tofile="${versionfile}"
filtering="on"
overwrite="true"
/>
</target>
<target name="clean">
<!-- If two builds are made within a minute -->
<delete dir="${dist}" quiet="true" />
<!-- Delete all previous temporary build artifacts -->
<delete dir="${target}" quiet="true" />
<delete file="${zipfile}" quiet="true"/>
<delete file="${javadoczip}" />
</target>
<macrodef name="junit_compilation">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<attribute name="classpath"/>
<sequential>
<mkdir dir="@{destdir}"/>
<javac
srcdir="@{srcdir}"
destdir="@{destdir}"
debug="on"
classpath="@{classpath}"
includeantruntime="false"
source="1.5"
target="1.5"
>
<compilerarg value="-Xlint:unchecked" />
</javac>
</sequential>
</macrodef>
<target name="build" depends="versiontag">
<junit_compilation srcdir="${src}" destdir="${bin}" classpath="${hamcrestlib}"/>
<unjar src="${hamcrestlib}" dest="${bin}" />
<junit_compilation srcdir="${testsrc}" destdir="${testbin}" classpath="${hamcrestlib};${bin}"/>
</target>
<target name="jars" depends="build">
<mkdir dir="${dist}" />
<jar
jarfile="${dist}/${srcjar}"
basedir="${src}"
excludes="${unjarred}, **/*.class"
/>
<jar
jarfile="${dist}/${binjar}"
basedir="${bin}"
excludes="${unjarred}, **/*.java, build.xml"
/>
<jar
jarfile="${dist}/${depjar}"
basedir="${bin}"
excludes="${unjarred}, org/hamcrest/**, **/*.java, build.xml"
/>
</target>
<target name="all.maven.jars" depends="jars,javadoc">
<mkdir dir="${dist}" />
<jar
jarfile="${dist}/${depsrcjar}"
basedir="${src}"
excludes="${unjarred}, **/*.class"
/>
<jar
jarfile="${dist}/${depdocjar}"
basedir="${javadocdir}"
excludes="${unjarred}, org/hamcrest/**"
/>
</target>
<target name="samples-and-tests">
<copy todir="${dist}">
<fileset dir="${testbin}" />
<fileset dir="${testsrc}" />
</copy>
</target>
<target name="unjar.hamcrest">
<unjar src="${hamcrestlibsources}" dest="${hamcrestsrc}" />
</target>
<target name="release-notes">
<property name="basename" value="doc/ReleaseNotes${version-base}" />
<exec executable="perl" failonerror="true">
<arg file="build/Markdown.pl"/>
<arg file="${basename}.md"/>
<redirector output="${basename}.html" />
</exec>
</target>
<target name="javadoc" depends="unjar.hamcrest">
<javadoc destdir="${javadocdir}"
author="false"
version="false"
use="false"
windowtitle="JUnit API"
stylesheetfile="src/main/javadoc/stylesheet.css"
>
<excludepackage name="junit.*" />
<excludepackage name="org.junit.internal.*" />
<excludepackage name="org.junit.experimental.theories.internal.*" />
<sourcepath location="${src}" />
<sourcepath location="${hamcrestsrc}" />
<link href="http://java.sun.com/javase/6/docs/api/" />
</javadoc>
</target>
<target name="javadoczip">
<delete file="${javadoczip}" />
<antcall target="javadoc" />
<zip basedir="${javadocdir}" file="${javadoczip}" />
</target>
<target name="populate-dist"
depends="clean, build, jars, samples-and-tests, javadoc, release-notes"
>
<copy todir="${dist}/doc">
<fileset dir="doc"/>
</copy>
<copy file="README.md" tofile="${dist}/README.md" />
<copy file="BUILDING" tofile="${dist}/BUILDING" />
<copy file="epl-v10.html" tofile="${dist}/epl-v10.html" />
<copy file="build.xml" tofile="${dist}/build.xml" />
</target>
<macrodef name="run-dist-tests">
<!-- Runs the tests against the built jar files -->
<element name="extra-args" implicit="yes" />
<sequential>
<java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true">
<extra-args />
<arg value="org.junit.tests.AllTests"/>
<classpath>
<pathelement location="${dist}" />
<pathelement location="${dist}/${binjar}" />
</classpath>
</java>
</sequential>
</macrodef>
<macrodef name="run-local-tests">
<!-- Runs the tests against the local class files -->
<sequential>
<java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true">
<arg value="org.junit.tests.AllTests"/>
<classpath>
<pathelement location="${bin}" />
<pathelement location="${testbin}" />
<pathelement location="${hamcrestlib}" />
</classpath>
</java>
</sequential>
</macrodef>
<target name="test" depends="build">
<run-local-tests />
</target>
<target name="dist" depends="populate-dist">
<run-dist-tests>
<jvmarg value="-Dignore.this=ignored"/>
</run-dist-tests>
</target>
<target name="profile" depends="populate-dist">
<run-dist-tests>
<jvmarg value="-agentlib:hprof=cpu=samples"/>
</run-dist-tests>
</target>
<target name="zip" depends="dist">
<zip zipfile="${zipfile}" basedir="." includes="${dist}/**" />
</target>
<target name="upload.to.sourceforge" depends="zip">
<ftp server="upload.sourceforge.net"
userid="anonymous"
password="[email protected]"
remotedir="incoming"
>
<fileset dir="${dist}" includes="*.jar" />
<fileset file="${zipfile}" />
</ftp>
<echo message="To upload docs, use build/upload_docs.sh" />
</target>
<!-- to do automatic build upload, you need the maven ant tasks jar. -->
<!-- therefore, you must run ant as ant -lib build/lib stage.maven -->
<macrodef name="push.maven.artifact">
<attribute name="file" />
<attribute name="pom" />
<attribute name="packaging" />
<attribute name="url" />
<attribute name="repo.id" />
<element name="artifact.args" implicit="true" optional="true" />
<sequential>
<artifact:mvn failonerror="true">
<arg value="${maven.deploy.goal}" />
<arg value="-Durl=@{url}" />
<arg value="-DrepositoryId=@{repo.id}" />
<arg value="-DpomFile=@{pom}" />
<arg value="-Dfile=@{file}" />
<arg value="-Dpackaging=@{packaging}" />
<artifact.args />
<arg value="-Pgpg" />
</artifact:mvn>
</sequential>
</macrodef>
<macrodef name="push.maven.jar">
<attribute name="jar" />
<attribute name="pom" />
<attribute name="url" />
<attribute name="repo.id" />
<element name="artifact.args" implicit="true" optional="true" />
<sequential>
<echo message="Pushing JAR to Maven: @{jar} -> @{url}" />
<push.maven.artifact file="@{jar}" pom="@{pom}" packaging="jar"
url="@{url}" repo.id="@{repo.id}">
<artifact.args />
</push.maven.artifact>
</sequential>
</macrodef>
<macrodef name="push.maven.pom">
<attribute name="pom" />
<attribute name="url" />
<attribute name="repo.id" />
<element name="artifact.args" implicit="true" optional="true" />
<sequential>
<echo message="Pushing POM to Maven: @{pom} -> @{url}" />
<push.maven.artifact file="@{pom}" pom="@{pom}" packaging="pom"
url="@{url}" repo.id="@{repo.id}">
<artifact.args />
</push.maven.artifact>
</sequential>
</macrodef>
<macrodef name="push.junit.maven.artifact">
<attribute name="url" />
<attribute name="repo.id" />
<attribute name="is.snapshot" default="true" />
<sequential>
<local name="m.prefix" />
<property name="m.prefix" value="${dist}/junit-dep-${version}" />
<local name="m.jar" />
<property name="m.jar" value="${m.prefix}.jar" />
<local name="m.sources.jar" />
<property name="m.sources.jar" value="${m.prefix}-src.jar" />
<local name="m.javadoc.jar" />
<property name="m.javadoc.jar" value="${m.prefix}-javadoc.jar" />
<local name="m.pom" />
<property name="m.pom" value="${dist}/pom-junit.xml" />
<filter token="version" value="${version}" />
<copy
file="build/maven/junit-pom-template.xml"
tofile="${m.pom}"
filtering="on"
overwrite="true"
/>
<push.maven.jar jar="${m.jar}" pom="${m.pom}"
url="@{url}" repo.id="@{repo.id}" />
<if>
<equals arg1="@{is.snapshot}" arg2="false" />
<then>
<push.maven.jar jar="${m.sources.jar}" pom="${m.pom}"
url="@{url}" repo.id="@{repo.id}">
<arg value="-Dclassifier=sources" />
</push.maven.jar>
<push.maven.jar jar="${m.javadoc.jar}" pom="${m.pom}"
url="@{url}" repo.id="@{repo.id}">
<arg value="-Dclassifier=javadoc" />
</push.maven.jar>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="push.junit-dep.maven.artifact">
<attribute name="url" />
<attribute name="repo.id" />
<sequential>
<local name="m.pom" />
<property name="m.pom" value="${dist}/pom-junit-dep.xml" />
<filter token="version" value="${version}" />
<copy
file="build/maven/junit-dep-pom-template.xml"
tofile="${m.pom}"
filtering="on"
overwrite="true"
/>
<push.maven.pom pom="${m.pom}"
url="@{url}" repo.id="@{repo.id}" />
</sequential>
</macrodef>
<target name="stage.maven" depends="all.maven.jars">
<property name="stage.url"
value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
<property name="stage.repo.id" value="sonatype-nexus-staging" />
<push.junit.maven.artifact url="${stage.url}"
repo.id="${stage.repo.id}"
is.snapshot="false" />
<push.junit-dep.maven.artifact url="${stage.url}"
repo.id="${stage.repo.id}" />
</target>
<target name="snapshot.maven" depends="all.maven.jars">
<property name="snapshot.url"
value="https://oss.sonatype.org/content/repositories/snapshots/" />
<property name="snapshot.repo.id" value="sonatype-nexus-snapshots" />
<push.junit.maven.artifact url="${snapshot.url}"
repo.id="${snapshot.repo.id}" />
<push.junit-dep.maven.artifact url="${snapshot.url}"
repo.id="${snapshot.repo.id}" />
</target>
<target name="print.version">
<echo message="${version}" />
</target>
</project>