-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
executable file
·161 lines (142 loc) · 8.91 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
<?xml version="1.0"?>
<project name="appserver-io-apps/api" default="composer-init" basedir=".">
<!-- initialize ENV variable -->
<property environment="env" />
<!-- ==================================================================== -->
<!-- Generate a time stamp for further use in build targets -->
<!-- ==================================================================== -->
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HHmmss"/>
</tstamp>
<!-- initialize file based properties -->
<property file="${basedir}/build.properties"/>
<property file="${basedir}/build.default.properties"/>
<property file="${basedir}/build.${os.family}.properties"/>
<!-- initialize the library specific properties -->
<property name="codepool" value="vendor"/>
<!-- initialize the directory where we can find the real build files -->
<property name="vendor.dir" value ="${basedir}/src/${codepool}" />
<property name="build.dir" value="${vendor.dir}/appserver-io/build" />
<property name="php-target.dir" value="${basedir}/target"/>
<!-- ==================================================================== -->
<!-- Import the common build configuration file -->
<!-- ==================================================================== -->
<import file="${build.dir}/common.xml" optional="true"/>
<!-- ==================================================================== -->
<!-- Checks if composer has installed it's dependencies -->
<!-- ==================================================================== -->
<target name="is-composer-installed">
<condition property="composer.present">
<available file="${build.dir}" type="dir"/>
</condition>
</target>
<!-- ==================================================================== -->
<!-- Installs all dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-install" depends="is-composer-installed" unless="composer.present" description="Installs all dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev --ignore-platform-reqs install"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Updates composer dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-update" depends="is-composer-installed" if="composer.present" description="Updates composer dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev --ignore-platform-reqs update"/>
</exec>
</target>
<!-- ===================================================================== -->
<!-- Checks if the build- and deployment stub has already been initialized -->
<!-- ===================================================================== -->
<target name="composer-init">
<antcall target="composer-install"/>
<antcall target="composer-update"/>
</target>
<!-- ==================================================================== -->
<!-- Creates the Swagger configuration -->
<!-- ==================================================================== -->
<target name="swagger-it" description="Creates the Swagger configuration.">
<exec executable="src/vendor/bin/swagger">
<arg line="${php-src.dir} --exclude ${vendor.dir} --output ${php-target.dir}/${appserver.webapp.name}/swagger.json"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the target directory -->
<!-- ==================================================================== -->
<target name="copy" description="Copies the sources to the target directory.">
<!-- prepare the directory structure -->
<antcall target="prepare"/>
<!-- copy sources and resources to the target directory -->
<copy todir="${php-target.dir}/${appserver.webapp.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-src.dir}">
<include name="**/*" />
<exclude name="vendor/**" />
</fileset>
</copy>
<!-- install the composer library -->
<exec dir="${basedir}" executable="composer">
<env key="COMPOSER_VENDOR_DIR" value="${php-target.dir}/${appserver.webapp.name}/vendor" />
<arg line="--no-dev --optimize-autoloader --ignore-platform-reqs install" />
</exec>
<!-- remove all .git directories -->
<delete includeemptydirs="true">
<fileset dir="${php-target.dir}/${appserver.webapp.name}" includes="**/.git/" defaultexcludes="false"/>
</delete>
<!-- creates the Swagger configuration -->
<antcall target="swagger-it"/>
</target>
<!-- ==================================================================== -->
<!-- Copies any built package to the snapshot hosting server. -->
<!-- ==================================================================== -->
<target name="copy-to-hub" description="Uploads any built package to the file-server.">
<echo message="Now try to upload all builds to file-server"/>
<exec executable="sh" failonerror="true">
<arg value="-c" />
<arg value="scp -o StrictHostKeyChecking=no -i ${user.home}/.ssh/id_rsa ${php-target.dir}/${package.filename} ${build.server.user}@${build.server.host}:${build.server.upload-path}" />
</exec>
<!-- update the latest remote package -->
<antcall target="update-latest-build" />
</target>
<!-- ==================================================================== -->
<!-- Will update the remote package indicating the latest successful -->
<!-- built unless the "omit.update-latest" property is true. -->
<!-- ==================================================================== -->
<target name="update-latest-build" unless="${omit.update-latest}" description="Will update the remote package indicating the latest successful built">
<echo message="Now try to update latest remote package"/>
<exec executable="sh" failonerror="true">
<arg value="-c" />
<arg value="scp -o StrictHostKeyChecking=no -i ${user.home}/.ssh/id_rsa ${php-target.dir}/${package.filename} ${build.server.user}@${build.server.host}:${build.server.upload-path}/${appserver.webapp.name}-latest.phar" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the deploy directory -->
<!-- ==================================================================== -->
<target name="deploy" depends="copy" description="Copies the sources to the deploy directory.">
<!-- copy the sources to the deploy directory -->
<echo message="Copy sources to ${deploy.dir} ..."/>
<copy todir="${appserver.webapps.dir}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-target.dir}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Creates a PHAR file for deployment -->
<!-- ==================================================================== -->
<target name="create-phar" depends="copy" description="Creates a PHAR file for deployment.">
<!-- create the PHAR archive itself from the backup sources -->
<exec dir="${php-target.dir}" executable="${vendor.dir}/bin/phar">
<arg line="-c create -n ${php-target.dir}/${package.filename} -d ${php-target.dir}/${appserver.webapp.name}"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Deploys the PHAR file into the configured deployment directory -->
<!-- ==================================================================== -->
<target name="deploy-phar" depends="create-phar"
description="Deploys the PHAR file into the configured deployment directory.">
<copy file="${php-target.dir}/${package.filename}" tofile="${appserver.deploy.dir}/${appserver.webapp.name}.phar" failonerror="true"/>
<!-- create dodeploy flag to be transmitted via scp and do deploy on target system if needed -->
<touch file="${appserver.deploy.dir}/${appserver.webapp.name}.phar.dodeploy"/>
</target>
</project>