-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
393 lines (344 loc) · 18.1 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
<?xml version="1.0" ?>
<!-- ****************************************************************************************************************
*
* $Id$
*
* http://httpunit.org/
* Copyright (c) 2002-2008 Russell Gold
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
**************************************************************************************************************** -->
<!-- ======================================================================= -->
<!-- httpunit build file -->
<!-- ======================================================================= -->
<project name="httpunit" default="jar" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property name="name" value="httpunit" />
<property name="Name" value="HttpUnit" />
<property name="version" value="1.7" />
<property name="revision" value="$Rev$" />
<property name="debug" value="on" />
<property name="deprecation" value="off" />
<property name="optimize" value="off" />
<property name="src.dir" value="src/main/java" />
<property name="tstsrc.dir" value="test/main/java" />
<property name="examples.dir" value="examples" />
<property name="website.dir" value="site" />
<property name="quicksite.dir" value="../quicksite/src" />
<property name="lib.dir" value="lib" />
<property name="jars.dir" value="jars" />
<property name="docs.dir" value="target/doc" />
<property name="build.dir" value="target" />
<property name="build.classes" value="${build.dir}/classes" />
<property name="test.classes" value="${build.dir}/testclasses" />
<property name="website.classes" value="${build.dir}/siteclasses" />
<property name="example.classes" value="${build.dir}/examples" />
<property name="javadoc.dir" value="${docs.dir}/api" />
<property name="dist.dir" value="target/dist" />
<property name="archive.dir" value="${dist.dir}/${name}-${version}" />
<property name="classpath" value="" />
<property name="web.dir" value="target/web" />
<property name="packages" value="com.meterware.httpunit,com.meterware.servletunit,com.meterware.pseudoserver,com.meterware.httpunit.cookies,com.meterware.httpunit.scripting,com.meterware.httpunit.parsing" />
<property name="test.class" value="com.meterware.httpunit.HttpUnitSuite" />
<property name="servlet.test.class" value="com.meterware.servletunit.ServletUnitSuite" />
<!-- =================================================================== -->
<!-- Prepares the build directory -->
<!-- =================================================================== -->
<target name="check_jars_dir">
<path id="check.path">
<fileset dir="${jars.dir}"/>
</path>
<condition property="have.local.jars">
<or>
<available classname="org.cyberneko.html.HTMLConfiguration" classpathref="check.path"/>
<available classname="org.w3c.tidy.Tidy" classpathref="check.path"/>
</or>
</condition>
</target>
<target name="prepare_local_classpath" depends="check_jars_dir" if="have.local.jars">
<echo message="using local classpath"/>
<path id="base.classpath">
<fileset id="distributed.jars" dir="${jars.dir}"/>
</path>
</target>
<!-- use maven ant-task to optionally download missing parts from maven repository -->
<target name="prepare_repository_classpath" depends="check_jars_dir" unless="have.local.jars">
<echo message="using repository classpath"/>
<typedef classpath="${jars.dir}/maven-ant-tasks-2.0.9.jar" resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" />
<artifact:dependencies pathId="base.classpath" fileSetId="distributed.jars">
<pom file="pom.xml"/>
</artifact:dependencies>
</target>
<target name="prepare" depends="prepare_local_classpath,prepare_repository_classpath">
<tstamp />
<mkdir dir="${build.dir}" />
</target>
<!-- =================================================================== -->
<!-- Check to see what optional dependencies are available -->
<!-- =================================================================== -->
<target name="check_for_optional_packages" depends="prepare">
<available property="jsdk.present" classname="javax.servlet.http.HttpServlet"
classpathref="base.classpath" />
<available property="javamail.present" classname="javax.mail.internet.MimeMultipart"
classpathref="base.classpath" />
<available property="jaxp.present" classname="javax.xml.parsers.DocumentBuilderFactory"
classpathref="base.classpath" />
<available property="rhino.present" classname="org.mozilla.javascript.Context"
classpathref="base.classpath" />
<available property="jtidy.present" classname="org.w3c.tidy.Tidy"
classpathref="base.classpath" />
<available property="nekoHTML.present" classname="org.cyberneko.html.HTMLConfiguration"
classpathref="base.classpath" />
<available property="junit.present" classname="junit.framework.Test"
classpathref="base.classpath" />
<condition property="dom3.absent">
<contains string="${java.version}" substring="1.4"/>
</condition>
</target>
<!-- =================================================================== -->
<!-- Compiles the source code -->
<!-- =================================================================== -->
<target name="compile-for-java2" depends="prepare,check_for_optional_packages" if="dom3.absent">
<mkdir dir="${build.classes}" />
<javac srcdir="src-1.4" destdir="${build.classes}"/>
</target>
<target name="compile" depends="prepare,check_for_optional_packages,compile-for-java2">
<mkdir dir="${build.classes}" />
<javac srcdir="${src.dir}" destdir="${build.classes}"
debug="${debug}" deprecation="${deprecation}" optimize="${optimize}">
<classpath refid="base.classpath" />
<exclude name="**/JTidyHTMLParser.java" unless="jtidy.present" />
<exclude name="**/ScriptFilter.java" unless="nekoHTML.present" />
<exclude name="**/NekoHTMLParser.java" unless="nekoHTML.present" />
<exclude name="**/NekoDOMParser.java" unless="nekoHTML.present" />
<exclude name="**/servletunit/*" unless="jsdk.present" />
<exclude name="**/JUnitServlet.java" unless="junit.present" />
<exclude name="**/javascript/*" unless="rhino.present" />
</javac>
</target>
<!-- =================================================================== -->
<!-- Compiles the example code -->
<!-- =================================================================== -->
<target name="compile-examples" depends="compile">
<mkdir dir="${example.classes}" />
<javac srcdir="${examples.dir}" destdir="${example.classes}"
debug="${debug}" deprecation="${deprecation}" optimize="${optimize}">
<classpath>
<path refid="base.classpath" />
<pathelement location="${build.classes}" />
</classpath>
</javac>
</target>
<!-- =================================================================== -->
<!-- Runs the main example -->
<!-- =================================================================== -->
<target name="run-example" depends="compile-examples">
<java fork="true" classname="Example" dir="${basedir}">
<classpath>
<path refid="base.classpath"/>
<pathelement location="${example.classes}"/>
<pathelement location="${build.classes}"/>
</classpath>
</java>
</target>
<!-- =================================================================== -->
<!-- Compiles the test code -->
<!-- =================================================================== -->
<target name="testcompile" depends="compile,check_for_optional_packages">
<mkdir dir="${test.classes}" />
<javac srcdir="${tstsrc.dir}" destdir="${test.classes}"
debug="on" deprecation="off" optimize="off">
<classpath>
<path refid="base.classpath" />
<pathelement location="${build.classes}" />
</classpath>
<exclude name="**/servletunit/*" unless="jsdk.present" />
<exclude name="**/FileUploadTest.java" unless="javamail.present" />
<exclude name="**/XMLPageTest.java" unless="jaxp.present" />
<exclude name="**/javascript/*" unless="rhino.present" />
<exclude name="**/JUnitServletTest.java" unless="junit.present" />
</javac>
<copy todir="${test.classes}">
<fileset dir="${tstsrc.dir}">
<include name="**/*.html"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- Runs the test code -->
<!-- =================================================================== -->
<target name="test" depends="testcompile" description="run JUnit Test Suite tests">
<java classname="${test.class}" fork="yes" >
<classpath>
<path refid="base.classpath" />
<pathelement location="${build.classes}" />
<pathelement location="META-INF" />
<pathelement location="${test.classes}" />
</classpath>
</java>
</target>
<!-- =================================================================== -->
<!-- Runs the test code -->
<!-- =================================================================== -->
<target name="servlettest" depends="testcompile" description="run JUnit servlet Suite tests">
<java classname="${servlet.test.class}" fork="yes" >
<classpath>
<path refid="base.classpath" />
<pathelement location="${build.classes}" />
<pathelement location="${test.classes}" />
</classpath>
</java>
</target>
<!-- =================================================================== -->
<!-- Creates the jar archive -->
<!-- =================================================================== -->
<target name="jar" depends="compile" description="create the jar file">
<mkdir dir="${lib.dir}" />
<echo file="${build.dir}/info.txt">Manifest-Version: 1.0
Sealed: false
HttpUnit-Version: ${version}
Build-Date: ${TODAY}
Build-Time: ${TSTAMP}
</echo>
<jar jarfile="${lib.dir}/${name}.jar" manifest="${build.dir}/info.txt">
<fileset dir="${build.classes}" includes="com/**"/>
<fileset dir="META-INF" includes="*.dtd"/>
</jar>
</target>
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
<target name="javadocs" depends="prepare">
<mkdir dir="${javadoc.dir}" />
<javadoc packagenames="${packages}" sourcepath="${basedir}/${src.dir}"
destdir="${javadoc.dir}" author="true" version="true"
windowtitle="${Name} ${version} API" doctitle="${Name}"
footer="Copyright &copy; 2000-2008 Russell Gold. See <a target="_top" href="../license.html">license agreement</A> for rights granted." >
<classpath refid="base.classpath"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Creates the tutorial archives -->
<!-- =================================================================== -->
<target name="tutorial" depends="jar">
<mkdir dir="${build.dir}/tutorial" />
<copy todir="${build.dir}/tutorial" >
<fileset dir="${docs.dir}/tutorial">
<include name="build.xml" />
<include name="web.xml" />
<include name="**/persistence/*.java" />
</fileset>
</copy>
<mkdir dir="${build.dir}/tutorial/jars" />
<zip zipfile="${docs.dir}/tutorial/task1.zip" basedir="${build.dir}/tutorial" includes="**" />
</target>
<!-- =================================================================== -->
<!-- Creates the distribution -->
<!-- =================================================================== -->
<target name="dist" depends="jar,javadocs,tutorial">
<mkdir dir="${archive.dir}" />
<copy todir="${archive.dir}" >
<fileset dir="." >
<include name="build.xml" />
<include name="readme.txt" />
<include name="index.html" />
<include name="site.css" />
<include name="favicon.ico" />
<include name="src/**" />
<include name="META-INF/**" />
<include name="test/**" />
<include name="examples/**" />
<include name="lib/*.*" />
<exclude name="**/activation.jar"/>
<exclude name="**/mailapi.jar" />
<include name="doc/**/*.*" />
<include name="doc/api/package-list" />
</fileset>
</copy>
<mkdir dir="${archive.dir}/jars"/>
<copy todir="${archive.dir}/jars">
<mapper type="flatten"/>
<fileset refid="distributed.jars" />
</copy>
</target>
<!-- =================================================================== -->
<!-- Packages the distribution with ZIP -->
<!-- =================================================================== -->
<target name="dist-zip" depends="dist" description="create the distribution with zip">
<zip zipfile="${name}-${version}.zip" basedir="${dist.dir}" includes="**" />
</target>
<!-- =================================================================== -->
<!-- Publishes to a web site -->
<!-- =================================================================== -->
<target name="publish" depends="dist-zip">
<mkdir dir="${web.dir}" />
<copy todir="${web.dir}" >
<fileset dir="." includes="site.css,favicon.ico,index.html,doc/**"/>
</copy>
<antcall target="update-website" />
</target>
<!-- =================================================================== -->
<!-- Compiles the website generator -->
<!-- =================================================================== -->
<target name="compile-site" depends="prepare">
<mkdir dir="${website.classes}" />
<javac srcdir="${website.dir}" destdir="${website.classes}"
debug="${debug}" deprecation="${deprecation}" optimize="${optimize}">
<classpath>
<pathelement location="${jars.dir}/quicksite.jar" />
<path refid="base.classpath" />
</classpath>
</javac>
</target>
<!-- =================================================================== -->
<!-- Updates the web site -->
<!-- =================================================================== -->
<target name="update-website" depends="compile-site">
<copy todir="${web.dir}">
<fileset dir="." includes="site.css,favicon.ico,doc/images/**,doc/tutorial/*.html" />
</copy>
<java classname="com.meterware.httpunit.site.WebSite" fork="yes" >
<classpath>
<path refid="base.classpath" />
<pathelement location="${website.classes}" />
<pathelement location="${jars.dir}/quicksite.jar" />
</classpath>
<arg path="${web.dir}"/>
</java>
</target>
<!-- =================================================================== -->
<!-- Packages the web site with ZIP -->
<!-- =================================================================== -->
<target name="publish-zip" depends="publish">
<zip zipfile="${name}_website_${version}.zip" basedir="${web.dir}" includes="**" />
</target>
<!-- =================================================================== -->
<!-- Cleans up generated stuff -->
<!-- =================================================================== -->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${web.dir}" />
</target>
<!-- =================================================================== -->
<!-- Total cleanup -->
<!-- =================================================================== -->
<target name="total-clean" depends="clean">
<delete file="${name}_*.zip" quiet="true" />
<delete dir="${docs.dir}/api" />
<delete dir="${docs.dir}/tutorial/*.zip" />
<delete dir="${lib.dir}" />
</target>
</project>