-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
365 lines (321 loc) · 15.4 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
<?xml version="1.0" encoding="utf-8"?>
<project default="init" name="Automaton" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="build/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask">
<classpath>
<pathelement location="build/lib/ant-jmeter-1.1.1.jar"/>
</classpath>
</taskdef>
<!-- Node properties for multiple instances on a single server. Ex: ant -Dnode.name=node01 build -->
<property file="./build/${node.name}.properties"/>
<property name="node.name" value="localhost"/>
<!-- Specify the server.name property via the Ant options. Ex: ant -Dserver.name=foo build -->
<property file="./build/${server.name}.properties"/>
<!-- The user.name system property is provided by the JVM, which reads the environment variable %USERNAME% or $USER -->
<property file="./build/${user.name}.properties"/>
<property name="project.version" value="1.0"/>
<property name="project.build" location="./build"/>
<property name="project.test" location="./test"/>
<property name="project.src" location="./src"/>
<property name="project.doc" location="./doc"/>
<property name="project.lib" location="./lib"/>
<property name="project.cache" location="./cache"/>
<property name="project.work" location="./work"/>
<property name="project.results" location="${project.build}/results"/>
<property name="project.cdn" value="http://cdn.automatonapp.com"/>
<import file="${project.build}/macrodefs/requirefile.xml"/>
<!-- Tomcat -->
<property name="tomcat.home" location="/var/lib/tomcat"/>
<property name="tomcat.vhosts" location="${tomcat.home}/vhosts"/>
<property name="tomcat.docbase" value="automaton"/>
<!-- CFML Engine -->
<property name="cfml.engine" value="railo-4"/>
<property name="cfml.engine.root" location="${tomcat.vhosts}/${tomcat.docbase}"/>
<property name="cfml.engine.webinf" location="${cfml.engine.root}/WEB-INF"/>
<property name="cfml.engine.webroot" value="${cfml.engine.root}"/>
<property name="cfml.engine.hostname" value="127.0.0.1"/>
<property name="cfml.engine.port" value="8080"/>
<!-- NGINX -->
<property name="nginx.root" value="/usr/share/nginx"/>
<property name="nginx.exec" value="/usr/sbin/nginx"/>
<property name="nginx.conf" value="/etc/nginx/conf.d"/>
<property name="nginx.hostname" value="automatonapp.com"/>
<property name="nginx.port" value="80"/>
<property name="nginx.log.path" value="/var/log/nginx"/>
<!-- ColdBox -->
<property name="coldbox.dist" value="coldbox_standalone_3.5.1.zip"/>
<!-- Webapp Properties -->
<property name="webapp.datasource" value="automaton"/>
<!-- MX Unit -->
<property name="mxunit.jar" location="${project.build}/lib/mxunit-ant.jar"/>
<property name="mxunit.dist" value="mxunit-framework-2.1.0.zip"/>
<property name="mxunit.outputdir" location="${project.results}"/>
<property name="mxunit.timeout" value="300"/>
<property name="mxunit.runner" value="/test/resources/HttpAntRunner.cfc?requestTimeout=${mxunit.timeout}"/>
<!-- VarScoper -->
<property name="varscoper.dist" value="varscoper4.zip"/>
<property name="varscoper.url" value="http://${nginx.app.server}:${nginx.app.port}/test/varscoper/varScoper.cfm"/>
<property name="varscoper.path" value="${cfml.engine.webroot}/model"/>
<property name="varscoper.recurse" value="true"/>
<property name="varscoper.outputfile" location="${project.results}/varscoper.csv"/>
<!-- ColdDoc -->
<property name="colddoc.dist" value="colddoc_v1.0.zip"/>
<property name="colddoc.output" value="${java.io.tmpdir}/colddoc.html"/>
<!-- Deploy information -->
<property name="deploy.environment" value="production"/>
<property name="deploy.reinit.password" value="CFML4EVER"/>
<property name="deploy.mail.server" value="localhost"/>
<tstamp>
<format property="deploy.release" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="deploy.hostname" value="${nginx.hostname}"/>
<property name="deploy.port" value="${nginx.port}"/>
<if>
<equals arg1="${deploy.port}" arg2="80"/>
<then>
<property name="deploy.baseurl" value="http://${deploy.hostname}/"/>
</then>
<else>
<property name="deploy.baseurl" value="http://${deploy.hostname}:${deploy.port}/"/>
</else>
</if>
<!-- HTTP Headers -->
<property name="http.appProxy.serverHostHeaderName" value="X-NGINX-Host"/>
<property name="http.appProxy.serverAddressHeaderName" value="X-NGINX-Server-IP"/>
<property name="http.appProxy.serverPortHeaderName" value="X-NGINX-Server-Port"/>
<property name="http.appProxy.clientAddressHeaderName" value="X-NGINX-Client-IP"/>
<property name="http.appProxy.schemeHeaderName" value="X-NGINX-Scheme"/>
<property name="http.geoIp.countryHeaderName" value="X-NGINX-GeoIP-Country"/>
<property name="http.geoIp.regionCodeHeaderName" value="X-NGINX-GeoIP-Region-Code"/>
<property name="http.geoIp.regionNameHeaderName" value="X-NGINX-GeoIP-Region-Name"/>
<property name="http.geoIp.cityHeaderName" value="X-NGINX-GeoIP-City"/>
<property name="http.geoIp.coordsHeaderName" value="X-NGINX-GeoIP-Coords"/>
<property name="http.geoIp.dmaCodeHeaderName" value="X-NGINX-GeoIP-DMA-Code"/>
<!-- jMeter Config -->
<property name="jmeter.home" location="jMeter"/>
<property name="jmeter.threads" value="10"/>
<property name="jmeter.loop" value="1"/>
<target name="init" description="Initialize working directory and perform sanity check.">
<echo message="Starting Ant from ${basedir} by user ${user.name}"/>
<fail message="The CFML engine root (${cfml.engine.root}) does not exist.">
<condition>
<not>
<available file="${cfml.engine.root}" type="dir"/>
</not>
</condition>
</fail>
<fail message="The CFML engine webroot (${cfml.engine.webroot}) does not exist.">
<condition>
<not>
<available file="${cfml.engine.webroot}" type="dir"/>
</not>
</condition>
</fail>
<delete dir="${project.work}"/>
<mkdir dir="${project.work}"/>
</target>
<target name="deploy-app" depends="init" description="Deploy CFML application to server.">
<echo message="Deploying the application to ${cfml.engine.webroot}"/>
<copy todir="${cfml.engine.webroot}/config" overwrite="true">
<fileset dir="${project.src}/config">
<include name="*.cfc"/>
<include name="*.cfm"/>
</fileset>
<filterset>
<filter token="VERSION" value="${project.version}"/>
<filter token="RELEASE" value="${deploy.release}"/>
<filter token="ENVIRONMENT" value="${deploy.environment}"/>
<filter token="REINIT_PASSWORD" value="${deploy.reinit.password}"/>
<filter token="NODE_NAME" value="${node.name}"/>
<filter token="DEPLOY_BASEURL" value="${deploy.baseurl}"/>
</filterset>
</copy>
<copy todir="${cfml.engine.webroot}" overwrite="true">
<fileset dir="${project.src}">
<include name="Application.cfc"/>
</fileset>
<filterset>
<filter token="DATASOURCE" value="${webapp.datasource}"/>
</filterset>
</copy>
<copy todir="${cfml.engine.webroot}" overwrite="true">
<fileset dir="${project.src}">
<exclude name="build/"/>
<exclude name="config/"/>
<exclude name="lib/"/>
<exclude name=".*"/>
<exclude name="Application.cfc"/>
<exclude name="ConnectionInspector.cfc"/>
<exclude name="settings.xml"/>
</fileset>
</copy>
<copy todir="${cfml.engine.webroot}" overwrite="true">
<fileset dir="${project.src}">
<include name="ConnectionInspector.cfc"/>
</fileset>
<filterset>
<filter token="APP_PROXY_SERVER_HOST_HEADER_NAME" value="${http.appProxy.serverHostHeaderName}"/>
<filter token="APP_PROXY_SERVER_ADDRESS_HEADER_NAME" value="${http.appProxy.serverAddressHeaderName}"/>
<filter token="APP_PROXY_SERVER_PORT_HEADER_NAME" value="${http.appProxy.serverPortHeaderName}"/>
<filter token="APP_PROXY_CLIENT_ADDRESS_HEADER_NAME" value="${http.appProxy.clientAddressHeaderName}"/>
<filter token="APP_PROXY_SCHEME_HEADER_NAME" value="${http.appProxy.schemeHeaderName}"/>
<filter token="GEOIP_COUNTRY_HEADER_NAME" value="${http.geoIp.countryHeaderName}"/>
<filter token="GEOIP_REGION_CODE_HEADER_NAME" value="${http.geoIp.regionCodeHeaderName}"/>
<filter token="GEOIP_REGION_NAME_HEADER_NAME" value="${http.geoIp.regionNameHeaderName}"/>
<filter token="GEOIP_CITY_HEADER_NAME" value="${http.geoIp.cityHeaderName}"/>
<filter token="GEOIP_COORDS_HEADER_NAME" value="${http.geoIp.coordsHeaderName}"/>
<filter token="GEOIP_DMA_CODE_HEADER_NAME" value="${http.geoIp.dmaCodeHeaderName}"/>
</filterset>
</copy>
</target>
<target name="deploy-libs" depends="init" description="Deploy all the libraries needed by the CFML application.">
<requirefile file="${project.cache}/${coldbox.dist}" url="${project.cdn}/dist/${coldbox.dist}"/>
<delete dir="${cfml.engine.webroot}/coldbox"/>
<unzip src="${project.cache}/${coldbox.dist}" dest="${cfml.engine.webroot}/coldbox"/>
</target>
<target name="deploy-nginx">
<if>
<os family="windows"/>
<then>
<!-- The Nginx configuration file (used outside this condition) needs directory separaters switched to slashes -->
<propertyregex property="nginx.app.webroot" input="${nginx.app.webroot}" regexp="\\" replace="/" override="true" global="true"/>
<!-- Copy the Nginx Windows Service files into place -->
<property name="deploy.nginx.conf" value="${nginx.conf}"/>
<copy file="${project.src}/config/nginx/service.xml" tofile="${nginx.root}/service/nginx.xml" overwrite="true">
<filterset>
<filter token="NGINX_EXEC" value="${nginx.exec}"/>
<filter token="NGINX_ROOT" value="${nginx.root}"/>
</filterset>
</copy>
<copy file="${project.lib}/winsw.exe" tofile="${nginx.root}/service/nginx.exe"/>
</then>
<else>
<!-- We'll place the Nginx configuration for non-Windows environments in the work path -->
<property name="deploy.nginx.conf" value="${project.work}/nginx"/>
<mkdir dir="${deploy.nginx.conf}"/>
</else>
</if>
<copy todir="${deploy.nginx.conf}" overwrite="true">
<fileset dir="${project.src}/config/nginx">
<include name="automaton.conf"/>
</fileset>
<filterset>
<filter token="NGINX_PORT" value="${nginx.port}"/>
<filter token="NGINX_HOSTNAME" value="${nginx.hostname}"/>
<filter token="NGINX_LOG_PATH" value="${nginx.log.path}"/>
<filter token="NGINX_APP_PORT" value="${nginx.app.port}"/>
<filter token="NGINX_APP_SERVER" value="${nginx.app.server}"/>
<!-- Different for Windows vs. non-Windows -->
<filter token="NGINX_APP_WEBROOT" value="${nginx.app.webroot}"/>
<filter token="APP_PROXY_SERVER_HOST_HEADER_NAME" value="${http.appProxy.serverHostHeaderName}"/>
<filter token="APP_PROXY_SERVER_ADDRESS_HEADER_NAME" value="${http.appProxy.serverAddressHeaderName}"/>
<filter token="APP_PROXY_SERVER_PORT_HEADER_NAME" value="${http.appProxy.serverPortHeaderName}"/>
<filter token="APP_PROXY_CLIENT_ADDRESS_HEADER_NAME" value="${http.appProxy.clientAddressHeaderName}"/>
<filter token="APP_PROXY_SECURE_ENDPOINT_HEADER_NAME" value="${http.appProxy.secureEndpointHeaderName}"/>
</filterset>
</copy>
<if>
<os family="mac"/>
<then>
<echo message="Nginx configuration file created in ${deploy.nginx.conf}."/>
</then>
</if>
</target>
<target name="deploy-unittests" depends="init" description="Deploy the MX Unit framework and all of the test cases.">
<requirefile file="${project.cache}/${mxunit.dist}" url="${project.cdn}/dist/${mxunit.dist}"/>
<delete dir="${cfml.engine.webroot}/mxunit"/>
<unzip src="${project.cache}/${mxunit.dist}" dest="${cfml.engine.webroot}/mxunit"/>
<copy todir="${cfml.engine.webroot}/test" overwrite="true">
<fileset dir="${project.test}">
<include name="Application.cfc"/>
</fileset>
<filterset>
<filter token="DATASOURCE" value="${webapp.datasource}"/>
</filterset>
</copy>
<copy todir="${cfml.engine.webroot}/test" overwrite="true">
<fileset dir="${project.test}">
<exclude name="Application.cfc"/>
</fileset>
</copy>
</target>
<target name="deploy-varscoper" depends="init" description="Deploy the files needed to run a varscoper test.">
<requirefile file="${project.cache}/${varscoper.dist}" url="${project.cdn}/dist/${varscoper.dist}"/>
<delete dir="${cfml.engine.webroot}/test/varscoper"/>
<mkdir dir="${cfml.engine.webroot}/test/varscoper"/>
<touch file="${cfml.engine.webroot}/test/varscoper/Application.cfc"/>
<unzip src="${project.cache}/${varscoper.dist}" dest="${cfml.engine.webroot}/test/varscoper">
<patternset>
<include name="display*.cfm"/>
<include name="fileDisplay.cfm"/>
<include name="index.cfm"/>
<include name="license.txt"/>
<include name="varScoper*.cf?"/>
</patternset>
</unzip>
</target>
<target name="deploy-colddoc" depends="init" description="Deploy the ColdDoc tool.">
<requirefile file="${project.cache}/${colddoc.dist}" url="${project.cdn}/dist/${colddoc.dist}"/>
<delete dir="${cfml.engine.webroot}/colddoc"/>
<unzip src="${project.cache}/${colddoc.dist}" dest="${cfml.engine.webroot}/colddoc">
<patternset>
<include name="colddoc/license.txt"/>
<include name="colddoc/ColdDoc.cfc"/>
<include name="colddoc/strategy/**"/>
</patternset>
<regexpmapper from="^colddoc/(.+)$$" to="\1"/>
</unzip>
</target>
<target name="undeploy" depends="init" description="Remove a deployed copy of the application and libraries.">
<echo message="Undeploying from ${cfml.engine.webroot}"/>
<delete includeemptydirs="true">
<fileset dir="${cfml.engine.webroot}">
<include name="**/*"/>
<exclude name="WEB-INF/"/>
<exclude name="META-INF/"/>
<exclude name="CFIDE/"/>
</fileset>
</delete>
</target>
<target name="test-unittests" depends="init" description="Run all of the MX Unit test files.">
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpath="${mxunit.jar}"/>
<delete dir="${project.results}"/>
<mkdir dir="${project.results}"/>
<mxunittask server="${cfml.engine.hostname}" port="${cfml.engine.port}" outputdir="${mxunit.outputdir}" defaultrunner="${mxunit.runner}">
<directory path="${cfml.engine.webroot}/test/unit" recurse="true" componentPath="test.unit"/>
</mxunittask>
</target>
<target name="test-varscoper" depends="init" description="Run a varscoper test.">
<get src="${varscoper.url}?displayformat=csv&filePath=${varscoper.path}&recursiveDirectory=${varscoper.recurse}" dest="${varscoper.outputfile}" verbose="false"/>
<loadfile srcfile="${varscoper.outputfile}" property="varscoper.csv">
<filterchain>
<headfilter skip="1"/>
<trim/>
</filterchain>
</loadfile>
<fail message="CFML var scope violation is found.">
<condition>
<isset property="varscoper.csv"/>
</condition>
</fail>
</target>
<target name="build-colddoc-html" depends="init" description="Deploy the mini-app and run it to generate HTML documentation in Javadoc style.">
<mkdir dir="${cfml.engine.webroot}/doc"/>
<copy todir="${cfml.engine.webroot}/doc" overwrite="true">
<fileset dir="${project.doc}">
<include name="**"/>
</fileset>
</copy>
<get src="http://${cfml.engine.hostname}:${cfml.engine.port}/doc/generate.cfm" dest="${colddoc.output}" verbose="false"/>
</target>
<target name="test-jmeter" description="Run jMeter load tests">
<jmeter jmeterhome="${jmeter.home}" testplan="${project.test}/jmeter/user-login.jmx" resultlog="${project.results}/jmeter/user-login.jtl">
<property name="request.threads" value="${jmeter.threads}"/>
<property name="request.loop" value="${jmeter.loop}"/>
</jmeter>
</target>
</project>