-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
490 lines (416 loc) · 17.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
485
486
487
488
489
490
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2007-2020 AREasy Runtime
~
~ This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed Software");
~ you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
~ License as published by the Free Software Foundation; either version 2.1 of the License,
~ or (at your option) any later version.
~
~ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT,
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-->
<project name="AREasy" basedir="." >
<!-- Environment properties -->
<property environment="env"/>
<!-- Load core properties and attributes -->
<property file="${basedir}/core.properties"/>
<!-- Define build folder -->
<property name="build.dir" value="${user.home}/.AREasy"/>
<property name="build.temp.dir" value="${build.dir}/temp"/>
<!-- Define sources folder (static and generated files) -->
<property name="src.dir" value="${basedir}/src"/>
<property name="src.java.dir" value="${src.dir}/java"/>
<property name="src.doc.dir" value="${src.dir}/doc"/>
<!-- Define libraries folder (static and generated files) -->
<property name="libs.dir" value="${basedir}/libs"/>
<property name="tools.dir" value="${libs.dir}/tools"/>
<!-- Define resources folder -->
<property name="res.dir" value="${basedir}/res"/>
<!-- Define distribution folder (static and generated files) -->
<property name="dist.dir" value="${build.dir}/dist/areasy"/>
<property name="dist.bin.dir" value="${dist.dir}/bin"/>
<property name="dist.cfg.dir" value="${dist.dir}/cfg"/>
<property name="dist.doc.dir" value="${dist.dir}/doc"/>
<property name="dist.libs.dir" value="${dist.dir}/libs"/>
<property name="library.jar" value="${project.name}.jar"/>
<property name="documentation.pdf" value="${project.name}.pdf"/>
<!-- availability of specific configuration file -->
<available file="${basedir}/deploy.properties" property="merge.config"/>
<!-- Configure ANT environment for new commands -->
<taskdef resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<fileset dir="${libs.dir}/tools" includes="ant-classloader*.jar"/>
</classpath>
</taskdef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<fileset dir="${libs.dir}/tools" includes="ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- Detect operating and activitae corresponding properties -->
<switch value="${os.name}">
<case value="Linux">
<property name="isUnix" value="true"/>
<property name="isWindows" value="false"/>
<property file="${basedir}/profile.unix.properties"/>
</case>
<case value="Unix">
<property name="isUnix" value="true"/>
<property name="isWindows" value="false"/>
<property file="${basedir}/profile.unix.properties"/>
</case>
<case value="Windows 7">
<property name="isUnix" value="false"/>
<property name="isWindows" value="true"/>
<property file="${basedir}/profile.windows.properties"/>
</case>
<case value="Windows 8">
<property name="isUnix" value="false"/>
<property name="isWindows" value="true"/>
<property file="${basedir}/profile.windows.properties"/>
</case>
<case value="Windows 8.1">
<property name="isUnix" value="false"/>
<property name="isWindows" value="true"/>
<property file="${basedir}/profile.windows.properties"/>
</case>
<case value="Windows 10">
<property name="isUnix" value="false"/>
<property name="isWindows" value="true"/>
<property file="${basedir}/profile.windows.properties"/>
</case>
<case value="Windows_NT">
<property name="isUnix" value="false"/>
<property name="isWindows" value="true"/>
<property file="${basedir}/profile.windows.properties"/>
</case>
</switch>
<!-- Builds Classpath -->
<path id="classpath.bin">
<fileset dir="${libs.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${tools.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Builds Classpath with Compiled AREasy libraries-->
<path id="classpath.ext">
<fileset dir="${libs.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${tools.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${dist.libs.dir}">
<include name="areasy*.jar"/>
</fileset>
</path>
<!-- up to dates-->
<uptodate property="uptodate-lib" targetfile="${dist.libs.dir}/${library.jar}">
<srcfiles dir="${src.java.dir}" includes="**/*.java"/>
<srcfiles dir="${src.java.dir}" includes="**/*.info"/>
</uptodate>
<uptodate property="uptodate-doc" targetfile="${dist.doc.dir}/${documentation.pdf}">
<srcfiles dir="${src.java.dir}" includes="**/*.java"/>
<srcfiles dir="${src.doc.dir}" includes="**/*.html"/>
</uptodate>
<!-- Cleans up the distribution files without generated classes. -->
<target name="0.Clean" description="Cleans up the distribution files (classes and documentation)">
<delete dir="${dist.dir}"/>
<delete dir="${build.temp.dir}"/>
</target>
<!-- Initializes the build. -->
<target name="1.Init" description="Initialize environment for tasks executed on this module">
<tstamp/>
<!-- Initialize custom Ant task needed for running the server tests -->
<delete dir="${build.temp.dir}"/>
<mkdir dir="${build.temp.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.cfg.dir}"/>
<mkdir dir="${dist.doc.dir}"/>
<mkdir dir="${dist.libs.dir}"/>
<echo message="---------- ${project.name} - ${project.fullname}, version ${project.version} ----------"/>
<echo message=""/>
<echo message="basedir = ${basedir}"/>
<echo message="java.home = ${java.home}"/>
<echo message="os = ${os.name}"/>
<echo message=""/>
</target>
<!-- Compiling procedure. -->
<target name="2.Bin" depends="1.Init" unless="uptodate-lib" description="Compile library">
<javac classpathref="classpath.bin" srcdir="${src.java.dir}" destdir="${build.temp.dir}"
debug="${compiler.debug}" deprecation="${compiler.deprecation}" optimize="${compiler.optimize}" nowarn="true">
</javac>
<!-- Copies non java files that need to be in the classes directory -->
<copy todir="${build.temp.dir}">
<fileset dir="${src.java.dir}/">
<include name="**/*.properties"/>
<include name="**/*.info"/>
<include name="**/*.xml"/>
<include name="**/*.dtd"/>
</fileset>
</copy>
<jar jarfile="${dist.bin.dir}/boot.jar">
<fileset dir="${build.temp.dir}">
<include name="org/areasy/boot/"/>
</fileset>
<manifest>
<attribute name="Product-Name" value="${project.name}"/>
<attribute name="Product-Description" value="${project.description}"/>
<attribute name="Product-Version" value="${project.version}"/>
<attribute name="Product-Vendor" value="${project.vendor}"/>
<attribute name="Product-Years" value="${project.years}"/>
<attribute name="Main-Class" value="org.areasy.boot.Main"/>
</manifest>
</jar>
<jar jarfile="${dist.libs.dir}/${library.jar}">
<fileset dir="${build.temp.dir}">
<include name="org/areasy/common/"/>
<include name="org/areasy/runtime/"/>
</fileset>
<manifest>
<attribute name="Product-Name" value="${project.name}"/>
<attribute name="Product-Description" value="${project.description}"/>
<attribute name="Product-Version" value="${project.version}"/>
<attribute name="Product-Vendor" value="${project.vendor}"/>
<attribute name="Product-Years" value="${project.years}"/>
<attribute name="Main-Class" value="org.areasy.runtime.RuntimeManager"/>
</manifest>
</jar>
</target>
<!-- Create environment -->
<target name="3.Dist" depends="2.Bin" description="Create distribution">
<mkdir dir="${dist.dir}/bin"/>
<mkdir dir="${dist.dir}/bin/tools"/>
<mkdir dir="${dist.dir}/work"/>
<mkdir dir="${dist.doc.dir}/samples"/>
<copy todir="${dist.dir}/bin">
<fileset dir="${src.dir}/env">
<exclude name=".svn/"/>
<include name="*.jar"/>
<include name="*.bat"/>
<include name="*.sh"/>
<include name="*.exe"/>
</fileset>
</copy>
<copy todir="${dist.dir}/bin/tools">
<fileset dir="${src.dir}/env/tools">
<exclude name=".svn/"/>
<include name="*.jar"/>
<include name="*.bat"/>
<include name="*.sh"/>
<include name="*.exe"/>
</fileset>
</copy>
<copy todir="${dist.cfg.dir}" overwrite="yes">
<fileset dir="${src.dir}/cfg">
<include name="*.properties"/>
</fileset>
</copy>
<copy todir="${dist.doc.dir}/samples">
<fileset dir="${src.doc.dir}/samples"/>
</copy>
<copy todir="${dist.doc.dir}/help">
<fileset dir="${src.doc.dir}/help"/>
</copy>
<copy todir="${dist.libs.dir}">
<fileset dir="${libs.dir}">
<include name="*.jar"/>
<include name="databases/*.jar"/>
</fileset>
</copy>
<if>
<equals arg1="${isWindows}" arg2="true"/>
<then>
<echo message="Prepare distribution for Windows environment"/>
<delete>
<fileset dir="${dist.dir}/bin" includes="*.sh"/>
<fileset dir="${dist.dir}/bin/tools" includes="*.sh"/>
</delete>
</then>
<else>
<echo message="Prepare distribution for Unix/Linux environment"/>
<delete>
<fileset dir="${dist.dir}/bin" includes="*.exe"/>
<fileset dir="${dist.dir}/bin" includes="*.bat"/>
<fileset dir="${dist.dir}/bin/tools" includes="*.bat"/>
</delete>
</else>
</if>
<if>
<equals arg1="${merge.config}" arg2="true"/>
<then>
<java classname="org.areasy.common.support.configuration.providers.properties.stream.ConfigurationManager" classpathref="classpath.ext">
<arg value="-configfile"/>
<arg value="${basedir}/deploy.properties"/>
<arg value="-remotepath"/>
<arg value="${dist.dir}/cfg"/>
</java>
</then>
</if>
</target>
<!-- Generates the module's API documentation -->
<target name="4.Doc" depends="3.Dist" unless="uptodate-doc" description="Generates API documentation">
<copy file="${src.doc.dir}/doclet.properties" tofile="${build.temp.dir}/doclet.properties" force="yes" overwrite="yes"/>
<copy file="${src.doc.dir}/documentation.html" tofile="${build.temp.dir}/documentation.html" force="yes" overwrite="yes"/>
<replace file="${build.temp.dir}/doclet.properties" token="%year%" value="${project.years}"/>
<replace file="${build.temp.dir}/doclet.properties" token="%vendor%" value="${project.vendor}"/>
<replace file="${build.temp.dir}/doclet.properties" token="%fullname%" value="${project.fullname}"/>
<replace file="${build.temp.dir}/doclet.properties" token="%version%" value="${project.version}"/>
<copy overwrite="true" todir="${build.temp.dir}">
<fileset dir="${src.doc.dir}">
<include name="documentation-*"/>
</fileset>
</copy>
<javadoc doclet="org.areasy.common.doclet.Doclet"
classpathref="classpath.bin"
maxmemory="256M" docletpathref="classpath.ext"
packagenames="org.areasy.*"
sourcepath="${src.java.dir}"
additionalparam="-pdf '${dist.doc.dir}/${documentation.pdf}' -config '${build.temp.dir}/doclet.properties'"
private="no"/>
</target>
<target name="5.Deploy" depends="4.Doc" description="Deploy distribution on local file system">
<echo message="Create AREasy distribution: ${deployment.path}"/>
<echo message="Creating file system structure.."/>
<mkdir dir="${deployment.path}"/>
<mkdir dir="${deployment.path}/bin"/>
<mkdir dir="${deployment.path}/bin/tools"/>
<mkdir dir="${deployment.path}/cfg"/>
<mkdir dir="${deployment.path}/doc"/>
<mkdir dir="${deployment.path}/doc/help"/>
<mkdir dir="${deployment.path}/libs"/>
<mkdir dir="${deployment.path}/logs"/>
<mkdir dir="${deployment.path}/work"/>
<if>
<equals arg1="${isWindows}" arg2="true"/>
<then>
<exec executable="icacls">
<arg value="${deployment.path}/logs"/>
<arg value="/grant"/>
<arg value="${user.name}:(f)"/>
</exec>
<exec executable="icacls">
<arg value="${deployment.path}/work"/>
<arg value="/grant"/>
<arg value="${user.name}:(f)"/>
</exec>
</then>
<else>
<exec executable="chmod">
<arg value="-R"/>
<arg value="777"/>
<arg value="${deployment.path}/logs"/>
</exec>
<exec executable="chmod">
<arg value="-R"/>
<arg value="777"/>
<arg value="${deployment.path}/work"/>
</exec>
</else>
</if>
<echo message="Deploying binary files.."/>
<copy todir="${deployment.path}/bin">
<fileset dir="${dist.bin.dir}"/>
</copy>
<copy todir="${deployment.path}/bin/tools">
<fileset dir="${src.dir}/env/tools"/>
</copy>
<echo message="Deploying configuration files.."/>
<copy todir="${deployment.path}/cfg" overwrite="yes">
<fileset dir="${dist.cfg.dir}"/>
</copy>
<echo message="Deploying libraries.."/>
<copy todir="${deployment.path}/libs">
<fileset dir="${dist.libs.dir}"/>
</copy>
<echo message="Deploying documentation files.."/>
<copy todir="${deployment.path}/doc">
<fileset dir="${dist.doc.dir}"/>
</copy>
</target>
<target name="6.Update" depends="2.Bin" description="Update deployment of configurations, help docs and libraries on existing local distribution">
<echo message="Update AREasy distribution: ${deployment.path}"/>
<echo message="Deploying libraries.."/>
<copy todir="${deployment.path}/bin">
<file name="${dist.bin.dir}/boot.jar"/>
</copy>
<copy todir="${deployment.path}/libs">
<file name="${dist.libs.dir}/${library.jar}"/>
</copy>
<echo message="Deploying configuration files.."/>
<copy todir="${deployment.path}/cfg" overwrite="yes">
<fileset dir="${src.dir}/cfg">
<include name="*.properties"/>
</fileset>
</copy>
<echo message="Deploying help documentation files.."/>
<copy todir="${deployment.path}/doc/help">
<fileset dir="${src.doc.dir}/help"/>
</copy>
<echo message="Removing log files and temporary files.."/>
<delete quiet="true">
<fileset dir="${deployment.path}/logs" includes="**/*.log"/>
<fileset dir="${deployment.path}/work" includes="**/*"/>
</delete>
</target>
<target name="7.Installer" depends="5.Deploy" description="Build installation kit">
<if>
<equals arg1="${isWindows}" arg2="true"/>
<then>
<copy file="${res.dir}/installer/win/installer.nsi" tofile="${build.temp.dir}/installer.nsi" force="yes" overwrite="yes"/>
<replace file="${build.temp.dir}/installer.nsi" token="%srcdir%" value="${res.dir}/installer/win"/>
<replace file="${build.temp.dir}/installer.nsi" token="%distdir%" value="${dist.dir}"/>
<replace file="${build.temp.dir}/installer.nsi" token="%name%" value="${project.name}"/>
<replace file="${build.temp.dir}/installer.nsi" token="%version%" value="${project.version}"/>
<replace file="${build.temp.dir}/installer.nsi" token="%vendor%" value="${project.vendor}"/>
<replace file="${build.temp.dir}/installer.nsi" token="%fullname%" value="${project.fullname}"/>
<!-- compile installer source -->
<exec executable="${nsis.path}/MakeNSIS.exe">
<arg path="${build.temp.dir}/installer.nsi"/>
</exec>
<delete file="${build.temp.dir}/installer.nsi" quiet="true"/>
</then>
<else>
<tar destfile="${build.temp.dir}/${project.name}-${project.version}.tar" basedir="${dist.dir}"/>
<gzip destfile="${build.temp.dir}/${project.name}-${project.version}.tar.gz" src="${build.temp.dir}/${project.name}-${project.version}.tar"/>
<delete file="${build.temp.dir}/${project.name}-${project.version}.tar" quiet="true"/>
<copyfile src="${res.dir}/installer/unix/installer.bin" dest="${build.temp.dir}/${project.name}.bin"/>
<mkdir dir="${build.temp.dir}/${project.name}"/>
<move file="${build.temp.dir}/${project.name}-${project.version}.tar.gz" todir="${build.temp.dir}/${project.name}"/>
<copyfile src="${res.dir}/installer/unix/setup.sh" dest="${build.temp.dir}/${project.name}/setup.sh"/>
<replace file="${build.temp.dir}/${project.name}/setup.sh" token="%name%" value="${project.name}"/>
<replace file="${build.temp.dir}/${project.name}/setup.sh" token="%version%" value="${project.version}"/>
<tar destfile="${build.temp.dir}/${project.name}.tar" basedir="${build.temp.dir}/${project.name}"/>
<gzip destfile="${build.temp.dir}/${project.name}.tar.gz" src="${build.temp.dir}/${project.name}.tar"/>
<concat destfile="${build.temp.dir}/${project.name}-${project.version}.bin" binary="yes">
<fileset file="${build.temp.dir}/areasy.bin"/>
<fileset file="${build.temp.dir}/areasy.tar.gz"/>
</concat>
<exec executable="/bin/chmod">
<arg line="+x '${build.temp.dir}/${project.name}-${project.version}.bin'"/>
</exec>
<delete dir="${build.temp.dir}/areasy" quiet="true"/>
<delete file="${build.temp.dir}/${project.name}.bin" quiet="true"/>
<delete file="${build.temp.dir}/${project.name}.tar" quiet="true"/>
<delete file="${build.temp.dir}/${project.name}.tar.gz" quiet="true"/>
</else>
</if>
</target>
<target name="8.Package" depends="5.Deploy" description="Build zip/gzip package">
<if>
<equals arg1="${isUnix}" arg2="true"/>
<then>
<tar destfile="${build.temp.dir}/${project.name}-${project.version}.tar" basedir="${dist.dir}"/>
<gzip destfile="${build.temp.dir}/${project.name}-${project.version}.tar.gz" src="${build.temp.dir}/${project.name}-${project.version}.tar"/>
<delete file="${build.temp.dir}/${project.name}-${project.version}.tar" quiet="true"/>
</then>
<else>
<zip destfile="${build.temp.dir}/${project.name}-${project.version}.zip" basedir="${dist.dir}"/>
</else>
</if>
</target>
</project>