-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.xml
More file actions
559 lines (505 loc) · 27.4 KB
/
build.xml
File metadata and controls
559 lines (505 loc) · 27.4 KB
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="appserver-io-dist/windows" default="dependencies-init" basedir=".">
<!-- ==================================================================== -->
<!-- Load the environment variables into our properties -->
<!-- ==================================================================== -->
<property environment="env" />
<!-- ==================================================================== -->
<!-- Generate a time stamp for further use in build targets -->
<!-- ==================================================================== -->
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HHmmss"/>
</tstamp>
<!-- ==================================================================== -->
<!-- Load all property files in the right order -->
<!-- ==================================================================== -->
<property file="${basedir}/build.properties"/>
<property file="${basedir}/build.default.properties"/>
<!-- ==================================================================== -->
<!-- Create some basic properties which we need for further processing. -->
<!-- ==================================================================== -->
<property name="src.dir" value="${work.dir}src" />
<property name="lib.dir" value="${work.dir}lib" />
<property name="target.dir" value="${work.dir}target" />
<property name="build.dir" value="${work.dir}build" />
<property name="tests.dir" value="${work.dir}tests" />
<property name="temp.dir" value="${work.dir}tmp" />
<property name="reports.dir" value="${work.dir}reports" />
<!-- ==================================================================== -->
<!-- Initialize the library specific properties -->
<!-- ==================================================================== -->
<property name="codepool" value="vendor"/>
<!-- ==================================================================== -->
<!-- Initialize the directory where we can find the real build files -->
<!-- ==================================================================== -->
<property name="dependency.dir" value ="${basedir}/${codepool}" />
<property name="package.dir" value="${dependency.dir}/package" />
<property name="package.remote-location" value="https://github.com/appserver-io-dist/package.git" />
<!-- ==================================================================== -->
<!-- Import the local tests/*files -->
<!-- ==================================================================== -->
<import file="${basedir}/tests/test.xml"/>
<!-- ==================================================================== -->
<!-- Import the package build files if they are present -->
<!-- ==================================================================== -->
<import file="${package.dir}/common.xml" optional="true" />
<!-- ==================================================================== -->
<!-- Cleans the target directories -->
<!-- ==================================================================== -->
<target name="clean">
<delete dir="${target.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
<delete dir="${temp.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
</target>
<!-- ==================================================================== -->
<!-- Cleans the build directories -->
<!-- ==================================================================== -->
<target name="clean-build" depends="prepare-build">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${build.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Cleans the reports directories -->
<!-- ==================================================================== -->
<target name="clean-reports" depends="prepare-reports">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${reports.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Prepares the target dir -->
<!-- ==================================================================== -->
<target name="prepare" depends="clean">
<mkdir dir="${target.dir}" />
<mkdir dir="${temp.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the reports environment -->
<!-- ==================================================================== -->
<target name="prepare-reports">
<mkdir dir="${reports.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the build environment -->
<!-- ==================================================================== -->
<target name="prepare-build">
<mkdir dir="${build.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Checks if the package helper libary is present -->
<!-- ==================================================================== -->
<target name="package-library-present">
<!-- check for the existence of the most central file of the package library -->
<available file="${package.dir}/common.xml" property="package-library.present" />
</target>
<!-- ==================================================================== -->
<!-- Loads all dependencies needed for the execution of build targets. -->
<!-- Not to be confused with the loading of dependencies needed for the -->
<!-- built packages! -->
<!-- ==================================================================== -->
<target name="dependencies-init" depends="package-library-present" unless="package-library.present">
<!-- create the target dir -->
<mkdir dir="${dependency.dir}" />
<!-- clone the latest version of our package library -->
<exec dir="${dependency.dir}" executable="git">
<arg line="clone ${package.remote-location}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Installs composer in target directory -->
<!-- ==================================================================== -->
<target name="install-composer">
<get src="http://getcomposer.org/installer" dest="${temp.dir}/composer-installer" />
<exec dir="${temp.dir}" executable="${target.dir}/appserver/php/php">
<arg value="composer-installer" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Check if appserver-io-php/runtime has been downloaded yet -->
<!-- ==================================================================== -->
<target name="check-runtime-present" description="Check if appserver-io-php/runtime has been downloaded yet.">
<!-- create runtime source package name -->
<create-package-name
tag="${appserver.runtime.version}"
outputProperty="RUNTIME_SOURCE_PACKAGE_NAME"
prefix="${build.name.prefix}runtime"
build="${appserver.runtime.build}"
suffixSeparator="."
versionSeparator="_"
architecture="${os.architecture}"
architectureSeparator="_"
extension="${appserver.runtime.package-extension}" />
<available file="${lib.dir}/${RUNTIME_SOURCE_PACKAGE_NAME}" property="runtime.present"/>
</target>
<!-- ==================================================================== -->
<!-- Get appserver-io/runtime package by given version number -->
<!-- ==================================================================== -->
<target name="get-runtime" depends="check-runtime-present" unless="runtime.present" description="Get appserver-io/runtime package by given version number.">
<get src="${appserver.runtime.url}/${RUNTIME_SOURCE_PACKAGE_NAME}" dest="${target.dir}/${RUNTIME_SOURCE_PACKAGE_NAME}"/>
</target>
<!-- ==================================================================== -->
<!-- Prepares the appserver sources -->
<!-- ==================================================================== -->
<target name="prepare-runtime" depends="prepare" description="Prepares the appserver sources">
<!-- create runtime source package name -->
<create-package-name
tag="${appserver.runtime.version}"
outputProperty="RUNTIME_SOURCE_PACKAGE_NAME"
prefix="${build.name.prefix}runtime"
build="${appserver.runtime.build}"
suffixSeparator="."
versionSeparator="_"
architecture="${os.architecture}"
architectureSeparator="_"
extension="${appserver.runtime.package-extension}" />
<!-- download the appserver-io-php/runtime package -->
<antcall target="get-runtime" />
<!-- extract the runtime -->
<unzip src="${target.dir}/${RUNTIME_SOURCE_PACKAGE_NAME}" dest="${target.dir}"/>
<!-- copy runtime sources to target directory -->
<copy todir="${target.dir}/appserver" preservelastmodified="true" overwrite="true">
<fileset dir="${src.dir}/${os.architecture}">
<include name="**/*" />
</fileset>
</copy>
<!-- copy install resources to target directory -->
<copy todir="${target.dir}" preservelastmodified="true" overwrite="true">
<fileset dir="${src.dir}">
<include name="runtime/**/*" />
</fileset>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Prepares the appserver sources -->
<!-- ==================================================================== -->
<target name="prepare-appserver-dist" depends="prepare-runtime" description="Prepares the appserver sources">
<!-- install local composer -->
<antcall target="install-composer" />
<exec dir="${target.dir}" executable="git">
<arg line="clone https://${github.oauth.token}:x-oauth-basic@github.com/${appserver.src.repo} appserver-src" />
</exec>
<!-- get latest tag version -->
<exec dir="${target.dir}/appserver-src" executable="git" outputProperty="appserver.src.git.tag">
<arg line="describe --abbrev=0 --tags" />
</exec>
<property name="appserver.src.version" value="${appserver.src.git.tag}" />
<!-- checkout latest tag version -->
<echo message="Checkout latest tag version ${appserver.src.version}" />
<exec dir="${target.dir}/appserver-src" executable="git">
<arg line="checkout -q ${appserver.src.version}" />
</exec>
<!-- move the sources -->
<move todir="${target.dir}/appserver" includeemptydirs="true" >
<fileset dir="${target.dir}/appserver-src" includes="**/*"/>
</move>
<!-- remove .git db files and .gitignore file -->
<delete dir="${target.dir}/appserver/.git" includeemptydirs="true" />
<delete file="${target.dir}/appserver/.gitignore" />
<!-- create version name -->
<create-version-name
tag="${appserver.src.version}"
build="${build.number}"
suffixSeparator="+"
outputProperty="VERSION_NAME" />
<!-- create the file with the version number -->
<echo file="${target.dir}/appserver/etc/appserver/.release-version" message="${VERSION_NAME}" />
<!-- also add the github oauth token to the local installation -->
<exec dir="${target.dir}/appserver" executable="${target.dir}/appserver/php/composer.bat">
<arg line="config github-oauth.github.com ${github.oauth.token}"/>
</exec>
<!-- install the libraries -->
<exec dir="${target.dir}/appserver" executable="${target.dir}/appserver/php/composer.bat">
<arg line="install --prefer-dist --no-dev --no-interaction --ignore-platform-reqs --optimize-autoloader" />
</exec>
<!-- deploy the applications -->
<antcall target="deploy-default-webapps" />
<!-- copy install resources to target directory -->
<copy todir="${target.dir}" preservelastmodified="true" overwrite="true">
<fileset dir="${src.dir}">
<include name="dist/**/*" />
</fileset>
</copy>
<!-- move the .bat files -->
<move todir="${target.dir}/appserver">
<fileset dir="${target.dir}/dist">
<include name="appserver*.bat"/>
<include name="scripts/*.bat"/>
</fileset>
</move>
</target>
<!-- ==================================================================== -->
<!-- Get the latest versions of the default webapps -->
<!-- ==================================================================== -->
<target name="get-default-webapps" description="Get the latest versions of the default webapps">
<get src="${appserver.apps.api.url}" dest="${target.dir}/${appserver.apps.api.name}.phar" usetimestamp="true"/>
<get src="${appserver.apps.example.url}" dest="${target.dir}/${appserver.apps.example.name}.phar" usetimestamp="true"/>
</target>
<!-- ==================================================================== -->
<!-- Deploys the appserver.io default webapps -->
<!-- ==================================================================== -->
<target name="deploy-default-webapps" depends="get-default-webapps" description="Deploys the ApplicationServer default webapps.">
<copy todir="${target.dir}/appserver/deploy" file="${target.dir}/example.phar"/>
<copy todir="${target.dir}/appserver/var/deploy" file="${target.dir}/api.phar"/>
</target>
<!-- ==================================================================== -->
<!-- Creates the IzPack installer JAR file for the distribution -->
<!-- ==================================================================== -->
<target name="pack-dist" depends="prepare-appserver-dist" description="Creates the IzPack installer JAR file for the distribution.">
<!-- create distribution package name -->
<create-package-name
tag="${appserver.src.version}"
outputProperty="DIST_PACKAGE_NAME"
prefix="${build.name.prefix}dist"
build="${build.number}"
suffixSeparator="."
versionSeparator="_"
architecture="${os.architecture}"
architectureSeparator="_"
extension="${build.name.ext}" />
<!-- copy IzPack configuration + .bat files to the target directory -->
<copy todir="${target.dir}" file="${src.dir}/appserver-izpack-dist.xml">
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- extend the classpath with the IzPack JAR's -->
<path id="build.classpath">
<fileset dir="${izpack.installation.dir}">
<include name="lib/*.jar" />
</fileset>
</path>
<!-- declare the IzPack task -->
<taskdef name="izpack" classpathref="build.classpath" classname="com.izforge.izpack.ant.IzPackTask" />
<!-- create the IzPack installer JAR file -->
<izpack input="${target.dir}/appserver-izpack-dist.xml"
output="${build.dir}/${DIST_PACKAGE_NAME}"
installerType="standard"
inheritAll="true"
basedir="${target.dir}"
izPackDir=" ${izpack.installation.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the environment to create a binary version of the IzPack -->
<!-- installer JAR file -->
<!-- ==================================================================== -->
<target name="prepare-exe" depends="pack-dist" description="Prepares the environment to create a binary version of the IzPack installer JAR file">
<!-- clear the target directory -->
<antcall target="prepare" />
<!-- extract the Java runtime environment JRE -->
<untar compression="gzip" src="${lib.dir}/${jre.filename}" dest="${target.dir}/dist" />
<move todir="${target.dir}/dist/jre">
<fileset dir="${target.dir}/dist/${jre.version}" />
</move>
<!-- extract the 7z binaries -->
<unzip src="${lib.dir}/7za920.zip" dest="${target.dir}" />
<!-- copy the JAR file with the distribution -->
<copy todir="${target.dir}/dist">
<fileset dir="${build.dir}" includes="${DIST_PACKAGE_NAME}" />
</copy>
<!-- copy the SFX binary -->
<copy todir="${target.dir}">
<fileset dir="${lib.dir}" includes="7zSD.sfx" />
</copy>
<!-- copy the SFX configuration -->
<copy todir="${target.dir}">
<fileset dir="${src.dir}">
<include name="appserver-sfx.txt" />
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Creates a binary version of the IzPack installer JAR file -->
<!-- ==================================================================== -->
<target name="create-exe" depends="prepare-exe" description="Creates a binary version of the IzPack installer JAR file.">
<!-- create executable package name -->
<create-package-name
tag="${appserver.src.version}"
outputProperty="EXE_PACKAGE_NAME"
prefix="${build.name.prefix}dist"
build="${build.number}"
suffixSeparator="."
versionSeparator="_"
architecture="${os.architecture}"
architectureSeparator="_"
extension="${extractor.name.ext}" />
<!-- compress all of the files we need to down with 7zip -->
<exec executable="${target.dir}/7za.exe" failonerror="true">
<arg value="a" />
<arg value="-t7z" />
<arg value="-r" />
<arg value="${target.dir}/appserver.7z" />
<arg value="${target.dir}/dist" />
</exec>
<!-- concat the files we need together to produce a binary launcher -->
<concat destfile="${build.dir}/${EXE_PACKAGE_NAME}" binary="yes">
<fileset file="${lib.dir}/7zSD.sfx" />
<fileset file="${target.dir}/appserver-sfx.txt" />
<fileset file="${target.dir}/appserver.7z" />
</concat>
</target>
<!-- ==================================================================== -->
<!-- Publishes the recent build to any snapshot hubs, etc.. Not to be -->
<!-- mistaken for the "release" target -->
<!-- ==================================================================== -->
<target name="publish" description="Publishes the recent build to any snapshot hubs, etc..">
<echo message="Now starting publish cycle"/>
<!-- upload the build artifacts to the snapshot hub -->
<antcall target="copy-to-hub" />
</target>
<!-- ==================================================================== -->
<!-- Extracts version and suffix from a tag -->
<!-- ==================================================================== -->
<scriptdef name="create-version-name" language="javascript">
<attribute name="tag" />
<attribute name="build" />
<attribute name="outputproperty" />
<attribute name="suffixseparator" />
<![CDATA[
// load the attributes
var tag = attributes.get("tag");
var build = attributes.get("build");
var outputProperty= attributes.get("outputproperty");
var suffixSeparator = attributes.get("suffixseparator");
// declare version and version suffix
var versionName = '';
var resultSuffix = '';
var resultVersion = tag;
// try to extract the version suffix, e. g. beta1
if (tag.indexOf("-") !== -1) {
// try to load the suffix
resultVersion = tag.substring(0, tag.indexOf("-"));
resultSuffix = tag.replace(resultVersion + "-", "");
}
// initialize the version name
versionName = resultVersion;
// append the build number
if (build != "") {
versionName += "-" + build;
}
// append the suffix if available
if (resultSuffix != "") {
versionName += suffixSeparator + resultSuffix;
}
// store version in the output properties
project.setProperty(outputProperty, versionName);
]]>
</scriptdef>
<!-- ==================================================================== -->
<!-- Will create a Windows specific package name -->
<!-- ==================================================================== -->
<scriptdef name="create-package-name" language="javascript">
<attribute name="tag" />
<attribute name="build" />
<attribute name="prefix" />
<attribute name="extension" />
<attribute name="architecture" />
<attribute name="outputproperty" />
<attribute name="suffixseparator" />
<attribute name="versionseparator" />
<attribute name="architectureseparator" />
<![CDATA[
// declare the package name
var packageName = '';
// load the attributes
var tag = attributes.get("tag");
var build = attributes.get("build");
var prefix = attributes.get("prefix");
var extension = attributes.get("extension");
var architecture = attributes.get("architecture");
var outputProperty = attributes.get("outputproperty");
var suffixSeparator = attributes.get("suffixseparator");
var versionSeparator = attributes.get("versionseparator");
var architectureSeparator = attributes.get("architectureseparator");
// declare version and version suffix
var resultVersion = tag;
var resultSuffix = '';
// the package name ALWAYS starts with the prefix
packageName = prefix;
// try to extract the version suffix, e. g. beta1
if (tag.indexOf("-") !== -1) {
// try to load the suffix
resultVersion = tag.substring(0, tag.indexOf("-"));
resultSuffix = tag.replace(resultVersion + "-", "");
}
// append the extracted version
if (resultVersion != "") {
packageName += versionSeparator + resultVersion;
}
// append the build number
if (build != "") {
packageName += "-" + build;
}
// append the OS specific suffix separator
if (resultSuffix != "") {
packageName += suffixSeparator + resultSuffix;
}
// append the architecture
if (architecture != "") {
packageName += architectureSeparator + architecture;
}
// append the package extension
if (extension != "") {
packageName += "." + extension;
}
// store the result in output property
project.setProperty(outputProperty, packageName);
]]>
</scriptdef>
<!-- ==================================================================== -->
<!-- Will prepare the environment to run a vagrant box in -->
<!-- ==================================================================== -->
<target name="prepare-build-environment" depends="prepare, clean-build, clean-reports">
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}">
<include name="build.*"/>
<include name="tests/*"/>
<include name="${codepool}/**"/>
</fileset>
</copy>
<!-- expand the properties within our box configuration -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir=".">
<include name="Vagrantfile"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- prepare a tmp dir for work within the VM -->
<mkdir dir="${temp.dir}/tmp" />
</target>
<!-- ==================================================================== -->
<!-- Creates all RPM packages within an existing vagrant box -->
<!-- ==================================================================== -->
<target name="vagrant-build">
<!-- map the vagrant name according to the expected environment -->
<property name="vagrant-box.name" value="${vagrant-box.prefix}Build" />
<!-- invoke original build target within vagrant box -->
<exec dir="${temp.dir}" executable="sh" errorproperty="build.failed">
<arg value="-c" />
<arg value="vagrant ssh-config | ssh -F /dev/stdin -l vagrant ${vagrant-box.name} 'ant local-build -buildfile ${vagrant.basedir}/build.xml -Dwork.dir=/ -Dgithub.oauth.token=${github.oauth.token} -Dbuild.number=${build.number} -Dtarget-os.version=${target-os.version} -Dappserver.runtime.version=${appserver.runtime.version} -Dappserver.runtime.build=${appserver.runtime.build} -Dappserver.src.version=${appserver.src.version}'" />
</exec>
<!-- eliminate the possiblity of empty but existing error output -->
<property name="build.failed" value=""/>
<condition property="fatal-error.occured" value="${build.failed}">
<not>
<equals arg1="${build.failed}" arg2=""/>
</not>
</condition>
<!-- check for an explicit build failure and make an emergency destroy -->
<antcall target="destroy-vagrant-box-on-error" />
<!-- tell them about any failures we might encountered -->
<fail if="fatal-error.occured" message="The build failed with message '${fatal-error.occured}', see log above." />
</target>
<!-- ==================================================================== -->
<!-- Creates the IzPack installer JAR file -->
<!-- ==================================================================== -->
<target name="local-build" description="Creates the IzPack installer JAR file.">
<antcall target="prepare-build" />
<antcall target="create-exe"/>
</target>
</project>