-
Notifications
You must be signed in to change notification settings - Fork 35
/
build.xml
452 lines (380 loc) · 13.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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="piggydb" default="all-in-one" basedir=".">
<property file="build.properties"/>
<import file="build-common.xml"/>
<import file="build-war-utils.xml"/>
<path id="libs-app">
<fileset dir="${lib.web.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.provided.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="libs-test">
<fileset dir="${lib.test.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="libs-it">
<fileset dir="${lib.it.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.it.dir}/htmlunit">
<include name="*.jar"/>
</fileset>
</path>
<path id="classpath-build-app">
<path refid="libs-app"/>
<path refid="libs-test"/>
</path>
<path id="classpath-build-test">
<path refid="libs-app"/>
<path refid="libs-test"/>
<pathelement location="${build.classes.dir}"/>
</path>
<path id="classpath-build-it">
<path refid="libs-test"/>
<path refid="libs-it"/>
<pathelement location="${build.utils-for-it.dir}"/>
</path>
<!--
Clean
-->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!--
Build classes
-->
<target name="build-classes">
<mkdir dir="${build.dir}"/>
<build-classes
src="${src.java.dir}"
encoding="${src.encoding}"
version="${src.version}"
resources="${src.resources.dir}"
classpath="classpath-build-app"
classes="${build.classes.dir}"/>
</target>
<!--
Unit tests
-->
<target name="test" depends="build-classes">
<build-classes
src="${src.test.dir}"
encoding="${src.encoding}"
version="${src.version}"
resources="${src.test-resources.dir}"
classpath="classpath-build-test"
classes="${build.test-classes.dir}"/>
<mkdir dir="${build.test-results.dir}"/>
<junit printsummary="yes" haltonfailure="yes">
<formatter type="brief" usefile="false"/>
<classpath>
<path refid="classpath-build-test"/>
<pathelement location="${build.test-classes.dir}"/>
</classpath>
<batchtest fork="yes" todir="${build.test-results.dir}">
<fileset dir="${build.test-classes.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</target>
<!--
Build war dir
-->
<target name="build-war-dir" depends="build-classes">
<mkdir dir="${build.war.dir}"/>
<copy todir="${build.war.dir}">
<fileset dir="${src.web.dir}"/>
</copy>
<mkdir dir="${build.war.dir}/WEB-INF/classes"/>
<copy todir="${build.war.dir}/WEB-INF/classes">
<fileset dir="${build.classes.dir}"/>
</copy>
<!-- Make the war dir into production -->
<replace dir="${build.war.dir}" value="${project.version}">
<include name="WEB-INF/spring/beans-ui.xml"/>
<replacetoken>@VERSION@</replacetoken>
</replace>
<replace file="${build.war.dir}/WEB-INF/click.xml">
<replacetoken><![CDATA[<mode value="development"/>]]></replacetoken>
<replacevalue><![CDATA[<mode value="production"/>]]></replacevalue>
</replace>
<replace file="${build.war.dir}/WEB-INF/web.xml" value="">
<replacetoken><![CDATA[<listener><listener-class>org.h2.server.web.DbStarter</listener-class></listener>]]></replacetoken>
</replace>
<copy
file="${build.war.dir}/WEB-INF/config/application-production.properties"
tofile="${build.war.dir}/WEB-INF/config/application.properties"
overwrite="true"/>
</target>
<!--
Production WAR
-->
<target name="war" depends="build-war-dir">
<!-- Make a production war -->
<build-war
warfile="${dist.dir}/${build.war.file.name}"
wardir="${build.war.dir}"/>
<!-- Make a production (anonymous version) war -->
<antcall target="_enable-anonymous"/>
<build-war
warfile="${dist.dir}/${build.war-anonymous.file.name}"
wardir="${build.war.dir}"/>
</target>
<target name="war-with-extensions" depends="build-war-dir, extensions-jar">
<copy file="${extensions.build.jar}" todir="${build.war.dir}/WEB-INF/lib" overwrite="true"/>
<antcall target="war"/>
</target>
<!--
All-in-one package
-->
<target name="all-in-one" depends="war">
<mkdir dir="${build.all-in-one.content.dir}"/>
<copy todir="${build.all-in-one.content.dir}">
<fileset dir="${src.all-in-one.dir}"/>
<fileset dir=".">
<include name="LICENSE.txt"/>
<include name="NOTICE.txt"/>
</fileset>
</copy>
<replace dir="${build.all-in-one.content.dir}" value="${build.war.file.name}">
<include name="run.bat"/>
<include name="run.sh"/>
<replacetoken>@WAR_FILE_NAME@</replacetoken>
</replace>
<copy
file="${dist.dir}/${build.war.file.name}"
tofile="${build.all-in-one.content.dir}/${build.war.file.name}"
overwrite="true"/>
<zip
zipfile="${dist.dir}/${build.all-in-one.name}.zip"
basedir="${build.all-in-one.dir}"/>
</target>
<!--
Piggydb Standalone Package ===========================================================
-->
<path id="libs-standalone">
<fileset dir="${standalone.lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="libs-launch4j">
<fileset dir="${standalone.lib.launch4j.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!--
Build standalone classes
-->
<target name="standalone-classes">
<mkdir dir="${standalone.build.dir}"/>
<build-classes
src="${standalone.src.java.dir}"
encoding="${src.encoding}"
version="${standalone.src.version}"
resources="${standalone.src.resources.dir}"
classpath="libs-standalone"
classes="${standalone.build.classes.dir}"/>
<replace dir="${standalone.build.classes.dir}" value="${project.version}">
<include name="**/VERSION"/>
<replacetoken>@VERSION@</replacetoken>
</replace>
</target>
<!--
Build standalone jar
-->
<target name="standalone-jar" depends="standalone-classes">
<pathconvert property="jar-classpath" dirsep="/" pathsep=" ">
<path refid="libs-standalone"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
<jar jarfile="${standalone.build.jar}">
<fileset dir="${standalone.build.classes.dir}"/>
<manifest>
<attribute name="Main-Class" value="marubinotto.piggydb.standalone.PiggydbServer"/>
<attribute name="Class-Path" value="${jar-classpath}"/>
<attribute name="SplashScreen-Image" value="splash.png"/>
</manifest>
</jar>
</target>
<!--
Build package base
-->
<target name="standalone-package-base" depends="standalone-jar, build-war-dir">
<mkdir dir="${standalone.build.package.dir}"/>
<copy file="${standalone.build.jar}" todir="${standalone.build.package.dir}" overwrite="true"/>
<copy todir="${standalone.build.package.dir}">
<fileset dir="${standalone.dir}">
<exclude name="**/.*"/>
<exclude name="**/.*/**"/>
<exclude name="src/**"/>
</fileset>
</copy>
<copy todir="${standalone.build.package.webapp.dir}">
<fileset dir="${build.war.dir}"/>
</copy>
<copy file="${standalone.build.package.webapp.dir}/WEB-INF/config/application.properties"
todir="${standalone.build.package.dir}" overwrite="true"/>
<copy todir="${standalone.build.package.dir}">
<fileset dir="${basedir}">
<include name="*.txt"/>
</fileset>
</copy>
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar"/>
<launch4j>
<config
headerType="gui"
jarPath="${standalone.build.jar}"
outfile="${standalone.build.package.dir}/${standalone.build.package.exe}"
dontWrapJar="false"
icon="${standalone.src.launch4j.dir}/piggydb.ico"
downloadUrl="http://java.com/download">
<jre minVersion="1.8.0"/>
</config>
</launch4j>
</target>
<!--
Build package
-->
<target name="standalone-package" depends="standalone-package-base">
<zip
zipfile="${dist.dir}/${standalone.build.package.name}.zip"
basedir="${standalone.build.dir}"
includes="${standalone.build.package.dir.name}/**"/>
</target>
<target name="standalone-package-supporters"
depends="standalone-package-base, extensions-jar, extensions-src">
<copy file="${extensions.build.jar}" todir="${standalone.build.package.webapp.dir}/WEB-INF/lib" overwrite="true"/>
<copy file="${extensions.build.src-zip}" todir="${standalone.build.package.dir}" overwrite="true"/>
<zip
zipfile="${build.dir}/${standalone.build.package.name}-supporters.zip"
basedir="${standalone.build.dir}"
includes="${standalone.build.package.dir.name}/**"/>
</target>
<!--
Extensions Jar
-->
<target name="extensions-jar" depends="build-classes">
<mkdir dir="${extensions.build.classes.dir}"/>
<build-classes
src="${extensions.dir}/src/java"
encoding="${src.encoding}"
version="${src.version}"
resources="${extensions.dir}/src/resources"
classpath="classpath-build-test"
classes="${extensions.build.classes.dir}"/>
<jar jarfile="${extensions.build.jar}">
<fileset dir="${extensions.build.classes.dir}"/>
</jar>
</target>
<!--
Extensions Source Zip
-->
<target name="extensions-src">
<zip
zipfile="${extensions.build.src-zip}"
basedir="${basedir}"
includes="extensions/**"
excludes="**/.*, **/.*/**"/>
</target>
<!--
Demo war files ==================================================================
-->
<target name="all-demo-wars">
<mkdir dir="${demo-wars.dir}"/>
<antcall target="clean"/><antcall target="war-jp"/>
<copy file="${build.dir}/ROOT.war" todir="${demo-wars.dir}" overwrite="true"/>
<antcall target="clean"/><antcall target="war-sandbox"/>
<copy file="${build.dir}/sandbox.war" todir="${demo-wars.dir}" overwrite="true"/>
<antcall target="clean"/><antcall target="war-en"/>
<copy file="${build.dir}/en.war" todir="${demo-wars.dir}" overwrite="true"/>
<antcall target="clean"/><antcall target="war-tt"/>
<copy file="${build.dir}/tt.war" todir="${demo-wars.dir}" overwrite="true"/>
<antcall target="clean"/><antcall target="war-example"/>
<copy file="${build.dir}/example.war" todir="${demo-wars.dir}" overwrite="true"/>
</target>
<!--
Prepare demo WAR
-->
<target name="prepare-demo" depends="build-war-dir, extensions-jar">
<!-- analytics code -->
<replace dir="${build.war.dir}">
<include name="border-template.htm"/>
<include name="document-view.htm"/>
<replacetoken>##TRACKING_CODE</replacetoken>
<replacevalue><![CDATA[
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5415340-11']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
]]></replacevalue>
</replace>
</target>
<!--
WAR for http://piggydb.jp/
-->
<target name="war-jp" depends="prepare-demo">
<copy file="${extensions.build.jar}" todir="${build.war.dir}/WEB-INF/lib" overwrite="true"/>
<antcall target="_enable-anonymous"/>
<antcall target="_set-default-scale-to-detail"/>
<antcall target="_enable-strict-edit-auth"/>
<antcall target="_enable-guest"/>
<build-war
warfile="${build.dir}/ROOT.war"
wardir="${build.war.dir}"/>
</target>
<!--
WAR for http://piggydb.jp/sandbox
-->
<target name="war-sandbox" depends="prepare-demo">
<antcall target="_enable-guest"/>
<build-war
warfile="${build.dir}/sandbox.war"
wardir="${build.war.dir}"/>
</target>
<!--
WAR for Piggydb Documents
-->
<target name="war-en" depends="prepare-demo">
<copy file="${extensions.build.jar}" todir="${build.war.dir}/WEB-INF/lib" overwrite="true"/>
<antcall target="_enable-anonymous"/>
<build-war
warfile="${build.dir}/en.war"
wardir="${build.war.dir}"/>
</target>
<!--
WAR for Table Tennis Videos
-->
<target name="war-tt" depends="prepare-demo">
<antcall target="_enable-anonymous"/>
<antcall target="_set-default-scale-to-detail"/>
<build-war
warfile="${build.dir}/tt.war"
wardir="${build.war.dir}"/>
</target>
<!--
WAR for Piggydb Knowledge Example
-->
<target name="war-example" depends="prepare-demo">
<antcall target="_enable-anonymous"/>
<antcall target="_set-default-scale-to-detail"/>
<build-war
warfile="${build.dir}/example.war"
wardir="${build.war.dir}"/>
</target>
</project>