-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
419 lines (355 loc) · 19.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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
Aug 29, 2019 12:35:05 PM
project IICS Reporting Tools
description
This Project contain IICS Reporting Tool
jbrazda
====================================================================== -->
<project name="IICS Reporting Build Script" default="help" basedir=".">
<description>
IICS Reportinmg Tools Build Script
</description>
<target name="-init">
<property file="build.properties" />
<property name="iics.reporting.config.location" location="${iics.reporting.config}" />
<property file="${iics.reporting.config.location}" />
<property environment="env" />
<condition property="isUnix">
<os family="unix" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="exec.ext" value="">
<os family="unix" />
</condition>
<condition property="exec.ext" value=".bat">
<os family="windows" />
</condition>
<condition property="shell" value="bash">
<os family="unix" />
</condition>
<condition property="shell" value="cmd.exe">
<os family="windows" />
</condition>
<condition property="shell.options" value="-c">
<os name="Mac OS X" />
</condition>
<condition property="shell.open" value=" open ">
<os name="Mac OS X" />
</condition>
<condition property="shell.open" value=" wslview ">
<and> <!-- Detecting WSL Linux runtime to open urls in windows default browser in wsl runtime -->
<os name="Linux"/>
<contains string="${os.version}" substring="WSL" />
</and>
</condition>
<condition property="shell.open" value=" start ">
<os family="windows" />
</condition>
<property name="shell.open" value="" />
<condition property="shell.options" value="-c">
<os family="unix" />
</condition>
<condition property="shell.options" value="/c">
<os family="windows" />
</condition>
<condition property="basex.bin" value="${basex.home}/bin">
<and>
<available file="${iics.reporting.config.location}" type="file"/>
</and>
</condition>
<path id="basex-PATH">
<pathelement path="${env.PATH}"/>
<pathelement path="${env.Path}"/>
<pathelement location="${basex.bin}"/>
</path>
<property name="PATH.basex" refid="basex-PATH"/>
<!-- BaseX Installation Checks-->
<condition property="available.basex" value="true" else="false">
<available filepath="${PATH.basex}" file="basex${exec.ext}" property="basex.present" />
</condition>
<condition property="available.basexgui" value="true" else="false">
<available filepath="${PATH.basex}" file="basexgui${exec.ext}" property="basexgui.present" />
</condition>
<condition property="available.basexhttp" value="true" else="false">
<available filepath="${PATH.basex}" file="basexhttp${exec.ext}" property="basexhttp.present" />
</condition>
<condition property="available.basexhttpstop" value="true" else="false">
<available filepath="${PATH.basex}" file="basexhttpstop${exec.ext}" property="basexhttpstop.present" />
</condition>
<property name="initialized" value="true" />
</target>
<target name="-env.info" unless="env.info.displayed" depends="-init">
<echo level="info">========================================</echo>
<echo level="info">== IICS Reporting Build ==</echo>
<echo level="info">========================================</echo>
<echo level="info">Java Version: ${java.runtime.version}</echo>
<echo level="info">Java Home: ${java.home}</echo>
<echo level="info">Ant Version: ${ant.version}</echo>
<echo level="info">Ant Lib: ${ant.library.dir}</echo>
<echo level="info">eclipse.home: ${eclipse.home}</echo>
<echo level="info">shell: ${shell}</echo>
<echo level="info">os.name: ${os.name}</echo>
<echo level="info">os.family: ${os.family}</echo>
<echo level="info">os.version: ${os.version}</echo>
<echo level="info">os.arch: ${os.arch}</echo>
<echo level="info">user.name: ${user.name}</echo>
<echo level="info">user.dir: ${user.dir}</echo>
<echo level="info">user.home: ${user.home}</echo>
<echo level="info">env.HOME: ${env.HOME}</echo>
<echo level="info">env.LANG: ${env.LANG}</echo>
<echo level="info">env.SHELL: ${env.SHELL}</echo>
<echo level="info">env.PATH: ${env.PATH}</echo>
<echo level="info">env.Path: ${env.Path}</echo>
<echo level="info">env.JAVA_HOME: ${env.JAVA_HOME}</echo>
<echo level="info">basex.home: ${basex.home}</echo>
<echo level="info">basex.bin: ${basex.bin}</echo>
<echo level="info">config.location: ${iics.reporting.config.location}</echo>
<echo level="info">available.basex: ${available.basex}</echo>
<echo level="info">available.basexhttp: ${available.basexhttp}</echo>
<echo level="info">available.basexhttpstop: ${available.basexhttpstop}</echo>
<echo level="info">available.basexgui: ${available.basexgui}</echo>
<echo level="info">========================================</echo>
<property name="env.info.displayed" value="true" />
</target>
<target name="help" depends="-env.info"
description="help - describes how to use this script">
<echo level="info">Script to Install And Run Reporting Tools</echo>
<echo level="info">Read the doc/README.MD or README.html for more details</echo>
<echo level="info">use ant -projecthelp to see available targets</echo>
<property name="help.file" location="${basedir}/README.md" />
<echo level="info">${shell.open} ${help.file}</echo>
<exec executable="${shell}" spawn="yes">
<arg value="${shell.options}" />
<arg value='${shell.open} ${help.file}'/>
</exec>
</target>
<target name="basex.download" depends="-env.info"
unless="${available.basex}"
description="Download BaseX">
<!-- Download OS Specific version of the tool-->
<echo level="info">Basex Available: ${available.basex}</echo>
<echo level="info">Downloading: ${basex.download.url}</echo>
<get src="${basex.download.url}" dest="${basex.downloads.dir}" usetimestamp="true" />
</target>
<target name="basex.download.update" depends="-env.info"
if="${available.basex}" description="Download BaseX Update">
<echo level="info">Basex Available: ${available.basex}</echo>
<echo level="info">Downloading: ${basex.upgrade.url}</echo>
<get src="${basex.upgrade.url}" dest="${basex.downloads.dir}/${basex.upgrade.file}" usetimestamp="true" verbose="true" />
</target>
<target name="basex.configure" depends="-env.info" description="Configure Reporting Tool">
<echo level="info">IICS Reporting Configuration:</echo>
<input defaultvalue="${default.basex.download.url}" message="BaseX Download URL:" addproperty="basex.download.url"/>
<property name="default.downloads.dir.location" location="${default.downloads.dir}" />
<input defaultvalue="${default.downloads.dir.location}" message="Download BaseX To: " addproperty="basex.downloads.dir"/>
<property name="default.basex.home.loaction" location="${default.basex.home}" />
<input defaultvalue="${default.basex.home.loaction}" message="Install BaseX To:" addproperty="basex.home"/>
<property name="default.basex.java_home.location" location="${env.JAVA_HOME}" />
<input defaultvalue="${java.home}" message="Set BaseX Java Home:" addproperty="basex.java_home"/>
<echoproperties destfile="${iics.reporting.config}">
<propertyset>
<propertyref prefix="basex." />
</propertyset>
</echoproperties>
<echo level="info">Configuration file written to ${iics.reporting.config}</echo>
</target>
<target name="install.all" description="Installs BaseX Tools, Deploys IICS Reporting App and runs BaseX HTTP server" depends="
basex.configure,
-init,
basex.install,
basexhttp.start,
basex.deploy.webapps">
</target>
<target name="basex.install" depends="basex.download"
unless="${available.basex}" description="Installs BaseX DB and Tools">
<mkdir dir="${basex.home}"/>
<unzip dest="${basex.home}/.." overwrite="true" src="${basex.downloads.dir}/${basex.download.file}">
</unzip>
<chmod perm="ugo+rx">
<fileset dir="${basex.home}/bin">
<include name="basex" />
<include name="basexcli" />
<include name="basexgui" />
<include name="basexhttp" />
<include name="basexhttpstop" />
<include name="basexserver" />
<include name="basexserverstop" />
</fileset>
</chmod>
<property name="available.basexhttp" value="true" />
</target>
<target name="upgrade.load.config">
<property file="build.properties" />
<property name="iics.reporting.config.location" location="${iics.reporting.config}" />
<property file="${iics.reporting.config.location}" />
</target>
<target name="upgrade.config" if="iics.reporting.basex.home"
depends="upgrade.load.config">
<echo level="info">Udating IICS Reporting Configuration:</echo>
<input defaultvalue="${default.basex.download.url}" message="BaseX Download URL:" addproperty="basex.download.url"/>
<property name="default.downloads.dir.location" location="${default.iics.reporting.downloads.dir}" />
<input defaultvalue="${default.downloads.dir.location}" message="Download BaseX To: " addproperty="basex.downloads.dir"/>
<property name="default.basex.home.loaction" location="${default.basex.home}" />
<input defaultvalue="${default.basex.home.loaction}" message="Install BaseX To:" addproperty="basex.home"/>
<property name="default.basex.java_home.location" location="${env.JAVA_HOME}" />
<input defaultvalue="${java.home}" message="Set BaseX Java Home:" addproperty="basex.java_home"/>
<echoproperties destfile="${iics.reporting.config}">
<propertyset>
<propertyref prefix="basex." />
</propertyset>
</echoproperties>
<echo level="info">Configuration file written to ${iics.reporting.config}</echo>
</target>
<target name="basex.upgrade" depends="upgrade.config,basexhttp.stop,basex.download.update" if="${available.basex}" description="Upgrades BaseX Runtime to Latest Version">
<delete verbose="true">
<fileset dir="${basex.home}">
<exclude name="data/**" />
<exclude name="webapp/iics/**" />
<exclude name="webapp/b2b/**" />
</fileset>
</delete>
<unzip dest="${basex.home}/.." overwrite="true" src="${basex.downloads.dir}/${basex.upgrade.file}">
</unzip>
<chmod perm="ugo+rx">
<fileset dir="${basex.home}/bin">
<include name="basex" />
<include name="basexcli" />
<include name="basexgui" />
<include name="basexhttp" />
<include name="basexhttpstop" />
<include name="basexserver" />
<include name="basexserverstop" />
</fileset>
</chmod>
<property name="available.basexhttp" value="true" />
</target>
<target name="confirm.basex.uninstall">
<input addproperty="basex.uninstall.confirmed" message="Do you really want to uninstall BaseX from ${basex.home}?" defaultvalue="no" validargs="yes,no">
</input>
</target>
<target name="basex.uninstall" depends="-env.info,basexhttp.stop,confirm.basex.uninstall" if="${basex.uninstall.confirmed}" description="Stops and Uninstall BaseX Server and Tools">
<delete dir="${basex.home}" failonerror="true" verbose="true" />
</target>
<target name="basexhttp.start" depends="-env.info,check.basexhttp.up" unless="${basex.http.up}" description="Run BaseX HTTP Server">
<exec executable="${basex.home}/bin/basexhttp${exec.ext}" spawn="true" dir="${basex.home}">
<env key="JAVA_HOME" value="${basex.java_home}" />
<env key="PATH" value="${PATH.basex}" />
</exec>
<waitfor checkevery="500" checkeveryunit="millisecond" maxwaitunit="minute" maxwait="1" timeoutproperty="basex.http.timeout">
<http url="${basex.http.base_url}/" />
</waitfor>
<fail if="basex.http.timeout" message="Timeout Waiting for BaseX HTTP Server to start" />
<echo level="info">Basex HTTP Started on ${basex.http.base_url}</echo>
<echo level="info">IICS Repoting available on ${basex.http.base_url}/iics</echo>
</target>
<target name="check.basexhttp.up" depends="-env.info">
<condition property="basex.http.up" value="true" else="false">
<and>
<http url="${basex.http.base_url}/" />
<equals arg1="${available.basexhttp}" arg2="true" />
</and>
</condition>
<echo level="info">Basex HTTP Available: ${available.basexhttp}</echo>
<echo level="info">Basex HTTP ${basex.http.base_url} UP: ${basex.http.up}</echo>
</target>
<target name="basexhttp.stop" depends="-env.info,check.basexhttp.up" if="${basex.http.up}" description="Stop BaseX HTTP Server">
<exec executable="${basex.home}/bin/basexhttpstop${exec.ext}" dir="${basex.home}">
<env key="JAVA_HOME" value="${basex.java_home}" />
<env key="PATH" value="${PATH.basex}" />
</exec>
</target>
<target name="basex.gui" depends="-env.info" if="${available.basexgui}" description="Start BaseX GUI">
<exec executable="${basex.home}/bin/basexgui${exec.ext}" dir="${basedir}" spawn="true">
<env key="JAVA_HOME" value="${basex.java_home}" />
<arg line="-d ${basedir}" />
</exec>
</target>
<target name="basex.deploy.webapps" depends="-env.info" if="${available.basexhttp}" description="Deploys Custom Webapps to BaseX Http Server to basex_home/webapp">
<copy todir="${basex.home}/webapp" verbose="true" overwrite="true">
<fileset dir="${basedir}/src/basex/webapp">
<include name="**" />
</fileset>
</copy>
<!-- Open Deployed web app in default browser -->
<property name="basex.app.url" value="${basex.http.base_url}/iics">
</property>
<exec executable="${shell}" spawn="yes">
<arg value="${shell.options}" />
<arg line="'${shell.open} ${basex.app.url}'" />
</exec>
</target>
<target name="project.update.from.basex" depends="-env.info" if="${available.basexhttp}" description="Updatesdeployed from basex http server webapp/iics dir ">
<copy todir="${basedir}/src/basex/webapp" verbose="true" overwrite="true">
<fileset dir="${basex.home}/webapp">
<include name="iics/**" />
</fileset>
</copy>
</target>
<target name="basex.create.db" depends="basex.install" description="Create new BaseX Database from Source file, archive or directory">
<fail unless="basex.create.db.name" message="Required property 'basex.create.db.name' is not set" />
<fail unless="basex.create.db.source" message="Required property 'basex.create.db.source' isn ot set" />
<basex.createDB dbname="${basex.create.db.name}" dbsource="${basex.create.db.source}" />
</target>
<target name="basex.drop.db" depends="basex.install" description="Drop Existing BaseX DB by name">
<fail unless="basex.drop.db.name" message="Required property 'basex.create.db.name' is not set" />
<basex.dropDB dbname="${basex.drop.db.name}" />
</target>
<target name="basex.sample.db.create" depends="-env.info"
description="Create Sample DEMO_DB">
<get src="${iics.reporting.sample.url}" dest="${basex.downloads.dir}/${iics.reporting.sample.file}" usetimestamp="true"/>
<antcall target="basex.create.db">
<param name="basex.create.db.name" value="DEMO_DB"/>
<param name="basex.create.db.source" value="${basex.downloads.dir}/${iics.reporting.sample.file}"/>
</antcall>
</target>
<target name="basex.sample.db.drop" depends="-env.info"
description="Drop Sample DEMO_DB">
<antcall target="basex.drop.db">
<param name="basex.drop.db.name" value="DEMO_DB"/>
</antcall>
</target>
<macrodef name="basex.createDB">
<attribute name="dbname" description="Database Name" />
<attribute name="dbsource" description="DB Source Directory, single xml file or zip file" />
<sequential>
<fail unless="${available.basex}" />
<property name="basex.command.createdb_@{dbname}" value='-c "CREATE DATABASE @{dbname} @{dbsource}"' />
<echo level="info">Running basex ${basex.command.createdb_@{dbname}}</echo>
<exec dir="${basedir}" executable="${basex.home}/bin/basex${exec.ext}">
<env key="JAVA_HOME" value="${basex.java_home}" />
<env key="PATH" value="${env.Path}${path.separator}${env.PATH}${path.separator}${basex.bin}" />
<arg line="${basex.command.createdb_@{dbname}}" />
</exec>
</sequential>
</macrodef>
<macrodef name="basex.dropDB">
<attribute name="dbname" description="Database Name" />
<sequential>
<fail unless="${available.basex}" />
<property name="basex.command.dropdb_@{dbname}" value='-c "DROP DATABASE @{dbname}"' />
<echo level="info">Running basex ${basex.command.dropdb_@{dbname}}</echo>
<exec dir="${basedir}" executable="${basex.home}/bin/basex${exec.ext}" failonerror="false">
<env key="JAVA_HOME" value="${basex.java_home}" />
<env key="PATH" value="${env.Path}${path.separator}${env.PATH}${path.separator}${basex.bin}" />
<arg line="${basex.command.dropdb_@{dbname}}" />
</exec>
</sequential>
</macrodef>
<macrodef name="basex.runXQ">
<attribute name="xq" description="Xquery Main Module" />
<attribute name="params" description="Parameters" default="" />
<sequential>
<fail unless="${available.basex}" />
<property name="basex.command.runxq_@{xq}" value='@{xq} @{params}' />
<echo level="info">Running basex ${basex.command.runxq_@{xq}}</echo>
<exec dir="${basedir}/xquery" executable="${basex.home}/bin/basex${exec.ext}">
<env key="JAVA_HOME" value="${basex.java_home}" />
<env key="PATH" value="${env.Path}${path.separator}${env.PATH}${path.separator}${basex.bin}" />
<arg line="${basex.command.runxq_@{xq}}" />
</exec>
</sequential>
</macrodef>
</project>