This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
forked from stweil/j2ep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
425 lines (306 loc) · 15.8 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
<project name="j2ep" default="compile" basedir=".">
<!--
The property file has to include to following properties.
* app.version - The version we are currently building.
* external.libs - Location for commons-beanutils, commons-codec
commons-digester and commons-httpclient.
* server.url - Url to the server, standard is http://localhost:8080.
You can also add params needed for the start of your container.
This build file can deploy to Tomcat and therefor the following
properties are added to build.properties.
* catalina.home - Tomcat location.
* manager.username - User name for the manager role.
* manager.password - Password for the manager role.
-->
<property file="build.properties"/>
<property file="build.properties.default"/>
<!--
Here are some properties used when building.
-->
<property name="app.name" value="j2ep"/>
<property name="build.home" value="${basedir}/WEB-INF/classes"/>
<property name="app.home" value="${basedir}/WEB-INF"/>
<property name="lib.home" value="${basedir}/WEB-INF/lib"/>
<property name="dist.home" value="${basedir}/dist"/>
<property name="docs.home" value="${basedir}/docs"/>
<property name="src.home" value="${basedir}/src"/>
<property name="test.relativehome" value="/net/sf/j2ep/test"/>
<property name="test.path" value="net.sf.j2ep.test"/>
<property name="reports.test" value="${basedir}/testreports"/>
<property name="manager.url" value="${server.url}/manager"/>
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize" value="true"/>
<!--
Dynamical construction of the classpath for ant.
-->
<path id="compile.classpath">
<!-- Include all the external libs -->
<fileset dir="${external.libs}">
<include name="*.jar" />
</fileset>
<!-- Base path included for the tests to relate to -->
<pathelement location="${build.home}"/>
</path>
<!--
Deletes all previous builds to clean up the filesystem.
-->
<target name="clean" description="Delete old build and dist directories">
<delete dir="${build.home}" />
<delete dir="${lib.home}" />
<delete dir="${dist.home}" />
<delete dir="${docs.home}/api" />
</target>
<!--
Compiles the source files to /WEB-INF/classes.
-->
<target name="compile" depends="prepare" description="Compile Java sources">
<!-- Compile Java classes -->
<mkdir dir="${build.home}" />
<javac source="1.4" target="1.4" srcdir="${src.home}" destdir="${build.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
<classpath refid="compile.classpath" />
</javac>
<!-- Copy application resources -->
<copy todir="${build.home}">
<fileset dir="${src.home}" excludes="**/*.java,**/*.class" />
</copy>
</target>
<!--
Will run the test cases for both junit and cactus.
-->
<target name="test" depends="cactusrelease,redeploy.cactuswar,deploy.cactuswar" description="Run all junit and cactus tests">
<!-- JUnit -->
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="compile.classpath" />
<formatter type="plain" />
<test name="net.sf.j2ep.test.AllowHeaderTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.CompositeRuleTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.DirectoryRuleTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.IPRuleTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.RewriteRuleTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.TimeRuleTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.StatusCheckerTest" todir="${reports.test}" />
</junit>
<!-- Cactus -->
<cactus warfile="${dist.home}/${app.name}-${app.version}-CACTUS.war" printsummary="yes">
<classpath refid="compile.classpath" />
<formatter type="plain" />
<test name="net.sf.j2ep.test.OptionTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.GetTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.PostTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.DirectoryMappingTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.ClusterTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.TraceTest" todir="${reports.test}" />
<test name="net.sf.j2ep.test.CycleTest" todir="${reports.test}" />
</cactus>
</target>
<!--
Makes a WAR file containing the test classes which are normally
not included in the WAR. Then the war i cactifyed so that the
tests can be run.
-->
<target name="cactusrelease" depends="compile" description="Create war for cactus test">
<!-- Create temporary dist directory -->
<mkdir dir="${dist.home}/tmp/WEB-INF" />
<copy todir="${dist.home}/tmp/WEB-INF">
<fileset dir="${app.home}" />
</copy>
<!-- We only want the web.xml that cactus is making for us -->
<move tofile="${dist.home}/tmp/WEB-INF/web.xml" overwrite="true" file="${dist.home}/tmp/WEB-INF/cactus-web.xml" />
<!-- Create application JAR file and cactify -->
<jar jarfile="${dist.home}/test.war" basedir="${dist.home}/tmp" />
<cactifywar srcfile="${dist.home}/test.war" destfile="${dist.home}/${app.name}-${app.version}-CACTUS.war" />
<!-- Remove tempdir -->
<delete dir="${dist.home}/tmp" />
<!-- Remove temporary war -->
<delete file="${dist.home}/test.war" />
<!-- Check if we have deployed a test relase already. We want to know if we should undeploy. -->
<waitfor maxwait="1000" checkevery="450" timeoutproperty="notdeployed">
<http url="${server.url}/test/ServletRedirector?Cactus_Service=RUN_TEST" />
</waitfor>
</target>
<!--
Make a jar of the class files for simple embedding.
-->
<target name="jar" depends="compile" description="Make a jar of the class files for simple embedding.">
<mkdir dir="${dist.home}" />
<jar jarfile="${dist.home}/${app.name}-${app.version}.jar">
<fileset dir="${build.home}" includes='**/*.class' excludes='**/test/*'/>
</jar>
</target>
<!--
Makes a release ready WAR file ready to deploy.
-->
<target name="release" depends="jar" description="Create binary distribution">
<!-- Create temporary dist directory -->
<mkdir dir="${dist.home}/tmp/WEB-INF" />
<copy todir="${dist.home}/tmp/WEB-INF">
<fileset dir="${app.home}" />
</copy>
<copy todir="${dist.home}/tmp/WEB-INF/lib" file="${dist.home}/${app.name}-${app.version}.jar"/>
<!-- Remove tests and classes from war -->
<delete includeemptydirs="true">
<fileset dir="${dist.home}/tmp/WEB-INF/classes" includes="**/*"/>
</delete>
<delete file="${dist.home}/tmp/WEB-INF/cactus-web.xml" />
<!-- Create application JAR file -->
<jar jarfile="${dist.home}/${app.name}-${app.version}.war" basedir="${dist.home}/tmp" />
<!-- Remove tempdir -->
<delete dir="${dist.home}/tmp" />
</target>
<!--
Creates two bzip and zip archive.
One as a release containing documentation, etc.
The other as a source relase including javadoc.
-->
<target name="distribute" depends="release,javadoc" description="Make everything ready to be uploaded to file server">
<tar destfile="${dist.home}/src.tar">
<tarfileset dir="${docs.home}" fullpath="/README">
<include name="readme-src.txt" />
</tarfileset>
<tarfileset dir="${docs.home}" fullpath="/LICENSE">
<include name="license.txt" />
</tarfileset>
<tarfileset dir="${docs.home}" prefix="/docs">
<exclude name="*.txt" />
</tarfileset>
<tarfileset dir="${src.home}" prefix="/src">
<include name="**/*.java"/>
<include name="**/*.xml"/>
</tarfileset>
<tarfileset dir="${basedir}" >
<include name="build.xml" />
<include name="build.properties.default" />
</tarfileset>
</tar>
<bzip2 src="${dist.home}/src.tar" destfile="${dist.home}/${app.name}-${app.version}-src.tar.bz2"/>
<zip destfile="${dist.home}/${app.name}-${app.version}-src.zip">
<zipfileset dir="${docs.home}" fullpath="README.txt">
<include name="readme-src.txt" />
</zipfileset>
<zipfileset dir="${docs.home}" fullpath="LICENSE">
<include name="license.txt" />
</zipfileset>
<zipfileset dir="${docs.home}" prefix="docs">
<exclude name="*.txt" />
</zipfileset>
<zipfileset dir="${src.home}" prefix="src">
<include name="**/*.java" />
<include name="**/*.xml" />
</zipfileset>
<zipfileset dir="${basedir}">
<include name="build.xml" />
<include name="build.properties.default" />
</zipfileset>
</zip>
<tar destfile="${dist.home}/release.tar">
<tarfileset dir="${docs.home}" fullpath="/README">
<include name="readme.txt" />
</tarfileset>
<tarfileset dir="${docs.home}" fullpath="/LICENSE">
<include name="license.txt" />
</tarfileset>
<tarfileset dir="${docs.home}" prefix="/docs">
<exclude name="*.txt" />
<exclude name="**/api/" />
</tarfileset>
<tarfileset dir="${dist.home}">
<include name="${app.name}-${app.version}.war" />
</tarfileset>
</tar>
<bzip2 src="${dist.home}/release.tar" destfile="${dist.home}/${app.name}-${app.version}.tar.bz2" />
<zip destfile="${dist.home}/${app.name}-${app.version}.zip">
<zipfileset dir="${docs.home}" fullpath="README.txt">
<include name="readme.txt" />
</zipfileset>
<zipfileset dir="${docs.home}" fullpath="LICENSE">
<include name="license.txt" />
</zipfileset>
<zipfileset dir="${docs.home}" prefix="docs">
<exclude name="*.txt" />
<exclude name="**/api/" />
</zipfileset>
<zipfileset dir="${dist.home}">
<include name="${app.name}-${app.version}.war" />
</zipfileset>
</zip>
<delete>
<fileset dir="${dist.home}">
<exclude name="${app.name}-${app.version}-src.zip"/>
<exclude name="${app.name}-${app.version}-src.tar.bz2"/>
<exclude name="${app.name}-${app.version}.zip"/>
<exclude name="${app.name}-${app.version}.tar.bz2"/>
</fileset>
</delete>
</target>
<!--
Creates javadoc API documentation for the classes.
No javadoc is created for the test classes.
-->
<target name="javadoc" depends="compile" description="Create Javadoc API documentation">
<mkdir dir="${docs.home}/api" />
<javadoc sourcepath="${src.home}" destdir="${docs.home}/api" excludepackagenames="${test.path}.*" packagenames="*">
<classpath refid="compile.classpath" />
</javadoc>
</target>
<!--
Tomcat specific deployment, change this to reflect your own container.
Will first undeploy the application.
-->
<target name="redeploy.cactuswar" unless="notdeployed">
<undeploy url="${manager.url}" username="${manager.username}" password="${manager.password}" path="/test" />
<deploy url="${manager.url}" username="${manager.username}" password="${manager.password}" path="/test" localWar="file://${dist.home}/${app.name}-${app.version}-CACTUS.war" />
</target>
<!--
Tomcat specific deployment, change this to reflect your own container.
-->
<target name="deploy.cactuswar" if="notdeployed">
<deploy url="${manager.url}" username="${manager.username}" password="${manager.password}" path="/test" localWar="file://${dist.home}/${app.name}-${app.version}-CACTUS.war" />
</target>
<!--
Creates the necesary folders.
-->
<target name="prepare">
<property name="commons-httpclient-3.0-rc3.jar" value="${external.libs}/commons-httpclient-3.0-rc3.jar" />
<property name="commons-digester-1.7.jar" value="${external.libs}/commons-digester-1.7.jar" />
<property name="commons-beanutils.jar" value="${external.libs}/commons-beanutils.jar" />
<property name="commons-codec-1.3.jar" value="${external.libs}/commons-codec-1.3.jar" />
<property name="commons-logging-1.0.4.jar" value="${external.libs}/commons-logging-1.0.4.jar" />
<!-- Create build directories as needed -->
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}"/>
<mkdir dir="${reports.test}"/>
<!-- Copy external dependencies as required -->
<mkdir dir="${lib.home}"/>
<copy todir="${lib.home}" file="${commons-httpclient-3.0-rc3.jar}"/>
<copy todir="${lib.home}" file="${commons-digester-1.7.jar}"/>
<copy todir="${lib.home}" file="${commons-beanutils.jar}"/>
<copy todir="${lib.home}" file="${commons-codec-1.3.jar}"/>
<copy todir="${lib.home}" file="${commons-logging-1.0.4.jar}"/>
<!-- Define the Cactus tasks -->
<taskdef resource="cactus.tasks" classpathref="compile.classpath" />
<!-- Tomcat specifc tasks -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="compile.classpath"/>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="compile.classpath"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="compile.classpath"/>
</target>
<!--
Downloads all the necesarry libarays to the external.libs
-->
<target name="download" description='Downloads all the necesarry libarays to the external.libs'>
<mkdir dir="${external.libs}" />
<get src="${download.libs}/cactus-ant-1.7.jar" dest="${external.libs}/cactus-ant-1.7.jar"/>
<get src="${download.libs}/commons-beanutils.jar" dest="${external.libs}/commons-beanutils.jar"/>
<get src="${download.libs}/commons-codec-1.3.jar" dest="${external.libs}/commons-codec-1.3.jar"/>
<get src="${download.libs}/commons-digester-1.7.jar" dest="${external.libs}/commons-digester-1.7.jar"/>
<get src="${download.libs}/commons-httpclient-3.0-rc3.jar" dest="${external.libs}/commons-httpclient-3.0-rc3.jar"/>
<get src="${download.libs}/commons-logging-1.0.4.jar" dest="${external.libs}/commons-logging-1.0.4.jar"/>
<get src="${download.libs}/aspectjrt-1.2.1.jar" dest="${external.libs}/aspectjrt-1.2.1.jar"/>
<get src="${download.libs}/cactus-1.7.jar" dest="${external.libs}/cactus-1.7.jar"/>
<get src="${download.libs}/xercesImpl.jar" dest="${external.libs}/xercesImpl.jar"/>
<get src="${download.libs}/junit.jar" dest="${external.libs}/junit.jar"/>
<get src="${download.libs}/catalina-ant.jar" dest="${external.libs}/catalina-ant.jar"/>
<get src="${download.libs}/servlet-api.jar" dest="${external.libs}/servlet-api.jar"/>
</target>
</project>