-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
341 lines (292 loc) · 8.84 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
<project name="Projektowanie Wnętrz - Renata Kowalczuk" default="help" basedir=".">
<!-- optional environmental settings -->
<property file="build.properties" />
<!-- setup default values -->
<property name="dir.base" location="." />
<property name="dir.build" location="${dir.base}/build" />
<property name="dir.build.out" location="${dir.build}/out" />
<property name="cmd.recess" value="${dir.base}/node_modules/.bin/recess" />
<property name="cmd.php" value="php" />
<property name="cmd.ant" value="ant" />
<property name="cmd.composer" value="${dir.base}/composer.phar" />
<property name="cmd.displayService" value="${dir.base}/displayService.phar" />
<!-- scp or ftp -->
<property name="use.scp" value="true" />
<property name="use.ftp" value="false" />
<available file="${cmd.composer}" property="composer.present" />
<available file="${cmd.displayService}" property="displayService.present" />
<available file="${cmd.recess}" property="recess.present" />
<!-- Deployment properties:
deploy.target
deploy.host
deploy.user
deploy.password
-->
<property name="deploy.images" value="true" />
<!--
Main targets:
- build
- deploy
- clean
- validate (todo)
-->
<target name="build"
description="Builds Website."
depends="clean"
>
<parallel>
<antcall target="build.css.compress" />
<antcall target="build.html" />
<antcall target="build.html.assets" />
<antcall target="build.html.gallery" />
</parallel>
<tar destfile="${dir.build}/renata-kowalczuk.eu.tgz"
basedir="${dir.build.out}"
compression="gzip"
/>
</target>
<target name="info"
description="Print information about deployment target"
>
<echo message="Will deploy to ${deploy.host}:${deploy.target}"/>
</target>
<target name="deploy"
description="Deploys the generated website to the remote server."
depends="deploy-scp,deploy-ftp"
/>
<target name="deploy-clean"
description="Cleans the remote server."
depends="deploy-clean-ftp"
/>
<target name="deploy-raw"
description="Deploys RAW website to the remote server."
depends="deploy-raw-ftp"
/>
<target name="deploy-scp" if="${use.scp}">
<scp file="${dir.out}/renata-kowalczuk.eu.tgz"
todir="${deploy.user}@${deploy.host}:${deploy.target}"
keyfile="${deploy.keyfile}"
/>
<sshexec host="${deploy.host}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
command="tar xzf ${deploy.target}/renata-kowalczuk.eu.tgz -C ${deploy.target}/public"
/>
</target>
<target name="deploy-ftp" if="${use.ftp}">
<echo message="Deployment to ${deploy.host}:${deploy.target}"/>
<ftp server="${deploy.host}"
remotedir="${deploy.target}"
userid="${deploy.user}"
password="${deploy.password}"
depends="yes"
>
<fileset dir="${dir.build.out}">
<include name="**"/>
</fileset>
</ftp>
</target>
<target name="deploy-clean-ftp" if="${use.ftp}">
<echo message="Cleaning ${deploy.host}:${deploy.target}"/>
<ftp action="del"
server="${deploy.host}"
remotedir="${deploy.target}"
userid="${deploy.user}"
password="${deploy.password}"
>
<fileset>
<include name="**"/>
</fileset>
</ftp>
<ftp action="rmdir"
server="${deploy.host}"
remotedir="${deploy.target}"
userid="${deploy.user}"
password="${deploy.password}"
>
<fileset>
<include name="**"/>
</fileset>
</ftp>
</target>
<target name="deploy-raw-ftp" if="${use.ftp}">
<echo message="RAW deployment to ${deploy.host}:${deploy.target}"/>
<ftp server="${deploy.host}"
remotedir="${deploy.target}"
userid="${deploy.user}"
password="${deploy.password}"
depends="yes"
>
<fileset dir=".">
<exclude name="build/**"/>
<exclude name="src/**"/>
<exclude name="legacy/**"/>
<include name="**/*.html"/>
<include name="**/*.js"/>
<include name="**/*.css"/>
<include name="**/*.less"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
<include name="favicon.ico" />
<include name=".htaccess" />
</fileset>
</ftp>
</target>
<target name="clean">
<echo level="info">Cleaning build folder</echo>
<delete dir="${dir.build}">
</delete>
</target>
<target name="validate"
description="Validates project."
depends="-install-composer, -install-displayService, -install-recess"
>
<!-- get dependencies -->
<exec executable="${cmd.php}" failonerror="true">
<arg line="${cmd.composer}" />
<arg line="update" />
<arg line="--no-dev" />
</exec>
</target>
<!--
CSS targets
- build.css.compress
- build.css.compile (todo)
- build.css.gfx
- build.css.watch
-->
<!-- Compressed, production ready CSS -->
<target name="build.css.compress"
depends="-install-recess, build.css.gfx"
description="Builds CSS file(s) and copy assets."
>
<echo level="info">Building ${dir.build.out}/static/styles/css/main.css</echo>
<mkdir dir="${dir.build.out}/static/styles/css/" />
<exec executable="${cmd.recess}" output="${dir.build.out}/static/styles/css/main.css">
<arg line="--compress" />
<arg line="${dir.base}/styles/less/main.less" />
</exec>
</target>
<target name="build.css.compile"
depends="-install-recess, build.css.gfx"
description="Builds CSS file(s) and copy assets."
>
<echo level="info">Building ${dir.build.out}/static/styles/css/main.css</echo>
<mkdir dir="${dir.build.out}/static/styles/css/" />
<exec executable="${cmd.recess}" output="${dir.build.out}/static/styles/css/main.css">
<arg line="--compress" />
<arg line="${dir.base}/styles/less/main.less" />
</exec>
</target>
<target name="build.css.gfx"
description="Copy css assets to build folder"
>
<echo level="info">Copying CSS images assets to build folder.</echo>
<mkdir dir="${dir.build.out}/static/styles/gfx/" />
<copy todir="${dir.build.out}/static/styles/gfx/">
<fileset dir="${dir.base}/styles/gfx/">
<include name="**.png" />
<include name="**.gif" />
</fileset>
</copy>
</target>
<target name="build.css.watch"
depends="-install-recess"
description="Prints command to run for watching CSS changes."
>
<echo>To watch CSS run following command</echo>
<echo>${cmd.recess} ${dir.base}/less/main.less:${dir.build.out}/static/styles/css/main.css --watch ${dir.base}/less/</echo>
</target>
<!--
HTML
- build.html
generate production HTML
- build.html.assets
copy all assets used on the page (images, PDFs, ...)
-->
<target name="build.html">
<mkdir dir="${dir.build.out}" />
<exec executable="${cmd.php}">
<env key="DS_HOSTDIR" value="${dir.base}" />
<arg line="${cmd.displayService}" />
<arg line="ds:generate" />
<arg line="--source='/'" />
<arg line="--output='${dir.build.out}'" />
</exec>
<!--
<copy todir="${dir.build.out}">
<fileset dir="${dir.base}">
<include name="index.html" />
<include name="contact.html" />
<include name="offer.html" />
</fileset>
</copy>
<exec executable="${cmd.php}">
<arg line="src/build-html.php" />
<arg line="${dir.build.out}/index.html" />
</exec>
<exec executable="${cmd.php}">
<arg line="src/build-html.php" />
<arg line="${dir.build.out}/contact.html" />
</exec>
<exec executable="${cmd.php}">
<arg line="src/build-html.php" />
<arg line="${dir.build.out}/offer.html" />
</exec>
-->
</target>
<target name="build.html.assets"
depends="build.html.assets.images"
>
<echo level="info">Copying assets to build folder.</echo>
<copy todir="${dir.build.out}">
<fileset dir="${dir.base}">
<include name="images/icons/*" />
<include name="images/index/*" />
<include name="images/logo*.png" />
<include name="favicon.ico" />
<include name=".htaccess" />
</fileset>
</copy>
</target>
<target name="build.html.assets.images" if="${deploy.images}">
<copy todir="${dir.build.out}">
<fileset dir="${dir.base}">
<include name="images/realizacje/**/*.jpg" />
</fileset>
</copy>
</target>
<target name="build.html.gallery">
<exec dir="${dir.base}" command="${cmd.php}">
<arg value="sgallery.php"/>
<arg value="update"/>
</exec>
</target>
<!--
trys to install composer locally using composer's install script
-->
<target name="-install-composer" unless="composer.present">
<exec executable="${cmd.php}" failonerror="true">
<arg value="-r" />
<arg value="eval('?>'.file_get_contents('https://getcomposer.org/installer'));" />
</exec>
</target>
<target name="-install-displayService" unless="displayService.present">
<get src="http://get.hoborglabs.com/displayService.phar" dest="${cmd.displayService}"/>
</target>
<target name="-install-recess" unless="recess.present">
<exec executable="npm">
<arg value="install" />
<arg value="recess" />
</exec>
<property name="cmd.recess" value="${dir.base}/node_modules/.bin/recess" />
</target>
<!-- Help Message -->
<target name="help"
description="Prints help"
>
<exec executable="${cmd.ant}">
<arg value="-p" />
</exec>
</target>
</project>