-
Notifications
You must be signed in to change notification settings - Fork 60
/
build.xml
484 lines (454 loc) · 19.3 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
<?xml version="1.0"?>
<project name="dwr" default="package" basedir=".">
<!-- For terminology, see the readme.txt file alongside this build file -->
<!--=======================================================================-->
<!-- File that contains local settings, you may need to edit this -->
<property file="build.properties" />
<!-- Properties for Maven Deploy, Stage, Release
See: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7c.DeploySnapshotsandStageReleaseswithAnt
-->
<property name="dist" location="dist" />
<!-- Version numbers: Duplicates the logic in VersionUtil.loadProperties() -->
<property file="${source.root}/core/impl/main/java/dwr-version.properties" />
<property name="version" value="${major}.${minor}.${revision}-${title}" />
<!-- define Maven coordinates -->
<property name="groupId" value="org.directwebremoting" />
<property name="artifactId" value="dwr" />
<!-- define artifacts' name, which follows the convention of Maven -->
<property name="dwr-maven-jar" value="${dist}/lib/${artifactId}-${version}.jar" />
<property name="dwr-maven-javadoc-jar" value="${dist}/lib/${artifactId}-${version}-javadoc.jar" />
<property name="dwr-maven-sources-jar" value="${dist}/lib/${artifactId}-${version}-sources.jar" />
<property name="dwr-maven-jdk14-jar" value="${dist}/lib/${artifactId}-${version}-jdk14.jar" />
<!-- End Properties for Maven -->
<!-- Get build number from Github CI -->
<property environment="envgithub"/>
<condition property="build.number" value="${envgithub.GITHUB_RUN_ID}">
<isset property="envgithub.GITHUB_RUN_ID" />
</condition>
<target name="init">
<mkdir dir="${build}" />
<mkdir dir="${dist}/lib" />
</target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<fileset dir="${source.root}/etc/ant" includes="**/*" />
</classpath>
</taskdef>
<!-- The modules that we are working with -->
<property name="modules" value="
core/api, core/impl, core/legacy,
protocol/dwrp, protocol/json,
serverside/spring, serverside/guice, serverside/struts, serverside/hibernate, serverside/webwork, serverside/various,
ui/dwr
" />
<!--=======================================================================-->
<target name="prepare" description="Various bits of setup">
<tstamp />
</target>
<!--=======================================================================-->
<target name="copy-sources">
<echo>Copying ${module} sources</echo>
<copy todir="${target.root}/sourcetree" overwrite="true">
<fileset dir="${module}/main/java" />
</copy>
</target>
<target name="source" description="Create dwr-src.jar">
<property name="java-sources" value="core/api, core/impl, core/legacy, protocol/dwrp, protocol/json,serverside/spring, serverside/guice, serverside/struts, serverside/hibernate, serverside/webwork, serverside/various, ui/dwr" />
<foreach list="${java-sources}" param="module" trim="true" target="copy-sources" />
<jar destfile="${target.root}/dwr-src.jar" compress="true">
<fileset dir="${target.root}/sourcetree" />
</jar>
<!-- Copy jar for Maven deploy/release -->
<copy file="${target.root}/dwr-src.jar" tofile="${dwr-maven-sources-jar}" />
</target>
<!-- Updates the pom.xml with the version -->
<target name="setVersionInPom">
<copy file="build/pom.xml" todir="target"/>
<replace casesensitive="false" file="target/pom.xml" token="{version}" value="${version}" />
</target>
<!-- Updates the build number in dwr-version.properties with the build number from CI -->
<target name="updateVersionPropertiesWithBuildNumber" description="Update dwr-version.properties with CI build number.">
<if>
<isset property="build.number" />
<then>
<propertyfile file="${target.root}/classes/main/dwr-version.properties">
<entry key="build.number" value="${build.number}" />
</propertyfile>
</then>
</if>
</target>
<!--=======================================================================-->
<target name="jar" depends="prepare, source" description="Create dwr.jar">
<build target="${target.root}" include="" modules="${modules}" />
<antcall target="setVersionInPom" />
<antcall target="updateVersionPropertiesWithBuildNumber" />
<jar destfile="${target.root}/dwr.jar" compress="true">
<fileset dir="${target.root}/classes/main" />
</jar>
<!-- Copy jar for Maven deploy/release -->
<copy file="${target.root}/dwr.jar" tofile="${dwr-maven-jar}" />
</target>
<!--=======================================================================-->
<target name="test" depends="jar" description="Create output for import into the testing project">
<jar destfile="${target.root}/junitdwr.jar" compress="true">
<fileset dir="${target.root}/classes/test" />
</jar>
</target>
<!--=======================================================================-->
<target name="war" depends="jar" description="Create an exploded dwrdemo.war">
<copy todir="${target.root}/web/demo/WEB-INF/classes">
<fileset dir="${target.root}/classes/demo" />
<!-- For people that download the war and want to see the source -->
<fileset dir="${source.root}/ui/dwr/demo/java" />
</copy>
<copy todir="${target.root}/web/demo/WEB-INF/lib">
<fileset file="${target.root}/dwr.jar" />
</copy>
</target>
<!--=======================================================================-->
<target name="package" depends="war, updateVersionPropertiesWithBuildNumber" description="Create packaged outputs: dwrdemo.war, dwr-jdk14.jar, and the source .zip">
<!-- Run retroweaver if dwr.jar has changed since we last ran it -->
<taskdef name="retroweaver" classname="net.sourceforge.retroweaver.ant.RetroWeaverTask">
<classpath>
<fileset dir="${source.root}/etc/retroweaver" includes="**/*" />
</classpath>
</taskdef>
<if-not-uptodate destfile="${basedir}/${target.root}/dwr-jdk14.jar" sourcedir="${target.root}/classes/main">
<action>
<!-- retroweaver is borked because it doesn't inherit directories properly
so if you call this ant build from another it gets the basedir wrong. so
we need to prefix the paths with ${basedir} -->
<retroweaver inputjar="${basedir}/${target.root}/dwr.jar" outputjar="${basedir}/${target.root}/dwr-jdk14.jar" target="1.4" />
</action>
</if-not-uptodate>
<copy file="${basedir}/${target.root}/dwr-jdk14.jar" tofile="${dwr-maven-jdk14-jar}" />
<!-- Rezip the demo war file if it's contents have changed -->
<if-not-uptodate destfile="${target.root}/dwrdemo.war" sourcedir="${target.root}/web/demo">
<action>
<zip destfile="${target.root}/dwrdemo.war" basedir="${target.root}/web/demo" />
</action>
</if-not-uptodate>
<!-- Copy over testdwr.war -->
<if>
<available file="${testdwr.home}/build.xml" />
<then>
<ant dir="${testdwr.home}" target="package" inheritall="false" inheritrefs="false" />
</then>
</if>
<if>
<available file="${testdwr.home}/target/ant/testdwr.war" />
<then>
<copy file="${testdwr.home}/target/ant/testdwr.war" todir="${target.root}" />
</then>
</if>
<!-- Documentation: Javadoc and DTDDoc -->
<mkdir dir="${target.root}/javadoc" />
<javadoc access="public" author="true" destdir="${target.root}/javadoc" doctitle="DWR Version ${version}" use="true" splitindex="true" version="true">
<sourcepath>
<pathelement path="${source.root}/core/api/main/java" />
<pathelement path="${source.root}/core/impl/main/java" />
<pathelement path="${source.root}/core/legacy/main/java" />
<pathelement path="${source.root}/protocol/dwrp/main/java" />
<pathelement path="${source.root}/protocol/json/main/java" />
<pathelement path="${source.root}/serverside/guice/main/java" />
<pathelement path="${source.root}/serverside/hibernate/main/java" />
<pathelement path="${source.root}/serverside/spring/main/java" />
<pathelement path="${source.root}/serverside/struts/main/java" />
<pathelement path="${source.root}/serverside/various/main/java" />
<pathelement path="${source.root}/serverside/webwork/main/java" />
<pathelement path="${source.root}/ui/dwr/main/java" />
</sourcepath>
<classpath>
<pathelement location="${target.root}/classes/main" />
<fileset dir="${target.root}/lib" includes="**/*.jar" />
</classpath>
<package name="org.directwebremoting.*" />
<footer>Copyright ¨ 2005 JS Foundation</footer>
</javadoc>
<!-- Jar docs for Maven release -->
<jar jarfile="${dwr-maven-javadoc-jar}">
<fileset dir="${target.root}/javadoc" />
</jar>
<path id="dtddocpath">
<fileset dir="${source.root}/etc/dtddoc" includes="**/*.jar" />
</path>
<taskdef name="DTDDoc" classname="DTDDoc.DTDDocTask" classpathref="dtddocpath" />
<mkdir dir="${target.root}/dtddoc" />
<DTDDoc showHiddenTags="false" showFixmeTags="false" sourceDir="${source.root}/core/impl/main/java" destDir="${target.root}/dtddoc" docTitle="DTDDoc's example">
<include name="**/*.dtd" />
<exclude name="common/*.dtd" />
</DTDDoc>
<!-- Source package -->
<zip destfile="${target.root}/dwr-${version}-src.zip">
<fileset dir="${source.root}">
<exclude name="target/**" />
<exclude name="**/*.iml" />
<exclude name="**/*.ipr" />
<exclude name="**/*.iws" />
</fileset>
<fileset dir="${target.root}">
<include name="dwr.jar" />
<include name="dwrdemo.war" />
</fileset>
<!-- The DWR website extracts javadoc from here -->
<zipfileset dir="${target.root}/javadoc" prefix="javadoc" />
</zip>
</target>
<!-- JSHint task. Checks for common JavaScript problems, coding conventions and other JavaScript coding issues -->
<taskdef name="jshint" classname="com.philmander.jshint.JsHintAntTask" classpath="build/lib/ant-jshint-0.3.4-deps.jar" />
<target name="jshint_scan">
<echo message="Checking JavaScript source with JSHint" />
<jshint dir="${source.root}" optionsFile="build/lib/jshint_options.properties">
<include name="**/main/java/org/directwebremoting/engine.js" />
<include name="**/main/java/org/directwebremoting/ui/servlet/util.js" />
</jshint>
</target>
<!--=======================================================================-->
<macrodef name="if-not-uptodate">
<!-- If you change this, remember the copy in testdwr/build.xml -->
<attribute name="destfile" />
<attribute name="sourcedir" />
<element name="action" />
<sequential>
<if>
<or>
<not>
<available file="@{destfile}" />
</not>
<not>
<uptodate targetfile="@{destfile}">
<srcfiles dir="@{sourcedir}" includes="**/*" />
</uptodate>
</not>
</or>
<then>
<action />
</then>
</if>
</sequential>
</macrodef>
<!--=======================================================================-->
<macrodef name="build" description="Create some distribution files from a set of modules">
<attribute name="modules" description="The set module to compile" />
<attribute name="target" description="The directory into which to build" />
<attribute name="include" description="The results of another build that we can depend on" />
<sequential>
<mkdir dir="@{target}/lib" />
<mkdir dir="@{target}/classes/main" />
<mkdir dir="@{target}/classes/test" />
<mkdir dir="@{target}/classes/demo" />
<mkdir dir="@{target}/web/demo/WEB-INF/classes" />
<mkdir dir="@{target}/web/demo/WEB-INF/lib" />
<foreach list="@{modules}" param="module" trim="true" target="process-module">
<param name="target" value="@{target}" />
<param name="include" value="@{include}" />
</foreach>
<foreach list="@{modules}" param="module" trim="true" target="run-tests-for-module">
<param name="target" value="@{target}" />
</foreach>
</sequential>
</macrodef>
<!--=======================================================================-->
<target name="process-module">
<echo message="Processing module: ${module}" />
<!-- copy jar files to the jar pool, to help suss the classpath -->
<if>
<available file="${source.root}/${module}/lib" />
<then>
<copy todir="${target}/lib" verbose="true">
<fileset dir="${module}/lib">
<include name="**/*.jar" />
</fileset>
</copy>
</then>
</if>
<!-- The main tree -->
<if>
<available file="${source.root}/${module}/main/java" />
<then>
<if>
<available file="${source.root}/${module}/generated/java" />
<then>
<compile-tree module="${module}" tree="main">
<sources>
<src path="${source.root}/${module}/main/java" />
<src path="${source.root}/${module}/generated/java" />
</sources>
</compile-tree>
<compile-copy module="${module}" tree="main" />
</then>
<else>
<compile-tree module="${module}" tree="main">
<sources>
<src path="${source.root}/${module}/main/java" />
</sources>
</compile-tree>
<compile-copy module="${module}" tree="main" />
</else>
</if>
</then>
</if>
<!-- The test tree -->
<if>
<available file="${source.root}/${module}/test/java" />
<then>
<compile-tree module="${module}" tree="test">
<sources>
<src path="${source.root}/${module}/test/java" />
</sources>
</compile-tree>
<compile-copy module="${module}" tree="test" />
</then>
</if>
<!-- The demo tree -->
<if>
<available file="${source.root}/${module}/demo/java" />
<then>
<compile-tree module="${module}" tree="demo">
<sources>
<src path="${source.root}/${module}/demo/java" />
</sources>
</compile-tree>
<compile-copy module="${module}" tree="demo" />
</then>
</if>
<!-- The demo web tree -->
<if>
<available file="${source.root}/${module}/demo/web" />
<then>
<copy todir="${target}/web/demo">
<fileset dir="${source.root}/${module}/demo/web" />
</copy>
</then>
</if>
</target>
<target name="run-tests-for-module" description="Run the JUnit tests for a module">
<echo message="Running tests for module: ${module}" />
<mkdir dir="${target}/junitReports" />
<if>
<available file="${source.root}/${module}/test/java" />
<then>
<junit printsummary="yes" fork="true" haltonfailure="yes">
<formatter type="xml" />
<classpath>
<fileset dir="${target}/lib" includes="**/*.jar" excludes="**/yuicompressor-2.3.5.jar" />
<pathelement location="${target.root}/classes/demo" />
<pathelement location="${target.root}/classes/main" />
<pathelement location="${target.root}/classes/test" />
<!-- needed for log4j -->
<fileset dir="${source.root}/ui/dwr/demo/web/WEB-INF/lib" includes="**/*" />
</classpath>
<batchtest todir="${target}/junitReports">
<fileset dir="${source.root}/${module}/test/java">
<include name="**/*Test.java" />
<include name="**/Test*.java" />
<exclude name="**/YahooJSCompressorTest.java" />
<!-- Not actually a test case, just a utility for helping with JSON tests -->
<exclude name="**/TestUtil.java" />
<!-- Not actually a test case -->
<exclude name="**/TestCreatedObject.java" />
<!-- In order to test this we need an db instance, too complicated for now -->
<exclude name="**/HibernateConverterTest.java" />
</fileset>
</batchtest>
<formatter type="plain" usefile="false" />
</junit>
<if>
<available file="${source.root}/${module}/test/java/org/directwebremoting/impl/YahooJSCompressorTest.java" />
<then>
<echo message="Running special test for yuicompressor" />
<junit printsummary="yes" fork="true" haltonfailure="yes">
<formatter type="xml" />
<classpath>
<fileset dir="${target}/lib">
<exclude name="js.jar" />
<exclude name="shrinksafe.jar" />
</fileset>
<pathelement location="${target.root}/classes/demo" />
<pathelement location="${target.root}/classes/main" />
<pathelement location="${target.root}/classes/test" />
<fileset dir="${source.root}/ui/dwr/demo/web/WEB-INF/lib" includes="**/*" />
</classpath>
<batchtest todir="${target}/junitReports">
<fileset dir="${source.root}/${module}/test/java">
<include name="**/YahooJSCompressorTest.java" />
</fileset>
</batchtest>
<formatter type="plain" usefile="false" />
</junit>
</then>
</if>
</then>
<else>
<echo message="Skipping, no tests exists for: ${module}" />
</else>
</if>
</target>
<!--=======================================================================-->
<macrodef name="compile-tree" description="Compile the sources from a set of trees">
<attribute name="module" description="The module to compile" />
<attribute name="tree" description="Must be one of [main|test|demo]" />
<element name="sources" />
<sequential>
<!-- compile the sources in @{module}/@{tree}/java into ${target}/classes/@{tree} -->
<if>
<equals arg1="${include}" arg2="" />
<then>
<javac debug="on" includes="**/*.java" destdir="${target}/classes/@{tree}" includeantruntime="false">
<exclude name="**/package.html" />
<exclude name="**/package-info.java" />
<sources />
<classpath>
<fileset dir="${target}/lib" includes="**/*.jar" />
<pathelement location="${target}/classes/main" />
</classpath>
</javac>
</then>
<else>
<javac debug="on" includes="**/*.java" destdir="${target}/classes/@{tree}" includeantruntime="false">
<exclude name="**/package.html" />
<exclude name="**/package-info.java" />
<sources />
<classpath>
<fileset dir="${target}/lib" includes="**/*.jar" />
<fileset dir="${include}/lib" includes="**/*.jar" />
<pathelement location="${target}/classes/main" />
<pathelement location="${include}/classes/main" />
</classpath>
</javac>
</else>
</if>
</sequential>
</macrodef>
<!--=======================================================================-->
<macrodef name="compile-copy" description="Compile the sources from a set of trees">
<attribute name="module" description="The module to compile" />
<attribute name="tree" description="Must be one of [main|test|demo]" />
<sequential>
<!-- copy the resources in @{module}/@{tree}/java into ${target}/classes/@{tree} -->
<copy todir="${target}/classes/@{tree}">
<fileset dir="${source.root}/@{module}/@{tree}/java">
<exclude name="**/*.java" />
<exclude name="**/package.html" />
<exclude name="**/package-info.java" />
</fileset>
</copy>
</sequential>
</macrodef>
<!--=======================================================================-->
<target name="generate-json-parser" description="Re-runs javacc on the JsonParser">
<mkdir dir="${source.root}/core/impl/generated/java/org/directwebremoting/json/parse/javacc" />
<javacc target="${source.root}/core/impl/main/javacc/JavaccJsonParser.jj" javacchome="${source.root}/core/impl/main/javacc" outputdirectory="${source.root}/core/impl/generated/java/org/directwebremoting/json/parse/javacc" />
</target>
<!--=======================================================================-->
<target name="clean" description="Remove all build targets and .DS_Store files left around by the Mac finder">
<echo message="Deleting everything from: ${target.root}" />
<delete verbose="true" dir="${target.root}" />
<echo message="Deleting **/*.DS_Store from: ${source.root}" />
<delete verbose="true">
<fileset defaultexcludes="false" dir="${source.root}">
<include name="**/*.DS_Store" />
</fileset>
</delete>
</target>
</project>