-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
build-test-plugins.xml
458 lines (389 loc) · 11.9 KB
/
build-test-plugins.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
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
<?xml version="1.0"?>
<project basedir="." default="test" name="portal-test-plugins" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="get-plugin-path">
<attribute name="plugin" />
<attribute name="plugin.types" />
<sequential>
<var name="plugin.path" unset="true" />
<var name="plugin.war" unset="true" />
<if>
<matches pattern="https?://" string="${test.build.plugins.war.zip.url}" />
<then>
<pathconvert pathsep="," property="plugin.war" setonempty="false">
<path>
<fileset
dir="plugins/marketplace"
includes="@{plugin}*.war"
/>
</path>
</pathconvert>
<if>
<isset property="plugin.war" />
<then>
<tstamp>
<format pattern="yyyyMMddkkmmssSSS" property="tstamp.value" />
</tstamp>
<mkdir dir="${tstamp.value}" />
<unzip
dest="${tstamp.value}"
src="${plugin.war}"
/>
<property name="plugin.path" value="${tstamp.value}" />
</then>
</if>
</then>
</if>
<if>
<available file="${lp.plugins.dir}/@{plugin.types}/@{plugin}" />
<then>
<property name="plugin.path" value="${lp.plugins.dir}/@{plugin.types}/@{plugin}" />
</then>
<else>
<pathconvert pathsep="," property="plugin.build.path" setonempty="false">
<path>
<fileset
dir="${project.dir}/modules"
includes="**/@{plugin}/build.gradle,**/@{plugin}/build.xml"
/>
</path>
</pathconvert>
<if>
<isset property="plugin.build.path" />
<then>
<dirname file="${plugin.build.path}" property="plugin.path" />
</then>
</if>
</else>
</if>
<if>
<not>
<isset property="plugin.path" />
</not>
<then>
<fail message="Unable to locate plugin @{plugin}" />
</then>
</if>
</sequential>
</macrodef>
<macrodef name="set-plugins-build-properties">
<sequential>
<get-auto-deploy-dir />
<if>
<equals arg1="${app.server.type}" arg2="tomcat" />
<then>
<if>
<equals arg1="${liferay.portal.bundle}" arg2="6.1.20" />
<then>
<property name="lp.plugins.app.server.dir" value="${app.server.parent.dir}/tomcat-7.0.27" />
</then>
<elseif>
<or>
<equals arg1="${liferay.portal.bundle}" arg2="6.2.0" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.1" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.2" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.3" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.1" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.2" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.3" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.4" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.5" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.6" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.7" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.8" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.9" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.10" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.11" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.12" />
<equals arg1="${liferay.portal.bundle}" arg2="6.2.10.13" />
</or>
<then>
<property name="lp.plugins.app.server.dir" value="${app.server.parent.dir}/tomcat-7.0.42" />
</then>
</elseif>
<elseif>
<contains string="@{liferay.portal.bundle}" substring="6.2" />
<then>
<property name="lp.plugins.app.server.dir" value="${app.server.parent.dir}/tomcat-7.0.62" />
</then>
</elseif>
</if>
</then>
</if>
<condition else="${app.server.dir}" property="lp.plugins.app.server.dir" value="${lp.plugins.app.server.dir}">
<isset property="lp.plugins.app.server.dir" />
</condition>
<echo append="true" file="${lp.plugins.dir}/build.${user.name}.properties">app.server.parent.dir=${app.server.parent.dir}
app.server.type=${app.server.type}
app.server.${app.server.type}.dir=${lp.plugins.app.server.dir}
auto.deploy.dir=${auto.deploy.dir}
liferay.home=${liferay.home}</echo>
</sequential>
</macrodef>
<target name="deploy-extra-apps">
<for list="${plugins.includes}" param="plugin">
<sequential>
<if>
<available file="extraapps" />
<then>
<pathconvert pathsep="," property="extraapps.zip" setonempty="false">
<path>
<fileset
dir="extraapps"
includes="@{plugin}*"
/>
</path>
</pathconvert>
</then>
</if>
<if>
<isset property="extraapps.zip" />
<then>
<get-auto-deploy-dir />
<unzip
dest="${auto.deploy.dir}"
src="${extraapps.zip}"
/>
</then>
<elseif>
<and>
<available file="plugins/marketplace" />
<isset property="marketplace.app[@{plugin}]" />
</and>
<then>
<local name="marketplace.app" />
<propertycopy from="marketplace.app[@{plugin}]" name="marketplace.app" />
<get-auto-deploy-dir />
<copy
file="plugins/marketplace/${marketplace.app}"
todir="${auto.deploy.dir}"
/>
</then>
</elseif>
</if>
</sequential>
</for>
</target>
<target name="deploy-simple-server-plugins">
<get-auto-deploy-dir />
<set-plugins-build-properties />
<for list="${plugins.includes}" param="plugin">
<sequential>
<if>
<matches pattern="https?://" string="@{plugin}" />
<then>
<mirrors-get
dest="${auto.deploy.dir}"
src="@{plugin}"
/>
</then>
<else>
<get-plugin-path
plugin="@{plugin}"
plugin.types="${plugin.types}"
/>
<get-testcase-property property.name="portlet.properties.@{plugin}" />
<if>
<isset property="portlet.properties.@{plugin}" />
<then>
<propertycopy from="portlet.properties.@{plugin}" name="portlet.properties" override="true" />
<if>
<available file="${plugin.path}/docroot/WEB-INF/src" />
<then>
<echo append="true" file="${plugin.path}/docroot/WEB-INF/src/portlet-ext.properties">${portlet.properties}</echo>
</then>
<else>
<echo append="true" file="${plugin.path}/WEB-INF/classes/portlet-ext.properties">${portlet.properties}</echo>
</else>
</if>
</then>
<else>
<delete file="${plugin.path}/docroot/WEB-INF/src/portlet-ext.properties" />
</else>
</if>
<if>
<equals arg1="@{plugin}" arg2="so-portlet" />
<then>
<echo file="${plugin.path}/overwrite/META-INF/custom_jsps/html/portlet/dockbar/license_warning.jsp" />
</then>
</if>
<if>
<equals arg1="${java.security}" arg2="true" />
<then>
<if>
<not>
<resourcecontains
resource="${plugin.path}/docroot/WEB-INF/liferay-plugin-package.properties"
substring="security-manager-enabled=true"
/>
</not>
<then>
<echo append="true" file="${plugin.path}/docroot/WEB-INF/liferay-plugin-package.properties">
security-manager-enabled=true</echo>
</then>
</if>
</then>
</if>
<if>
<isset property="plugin.war" />
<then>
<zip
basedir="${plugin.path}"
destfile="${plugin.war}"
update="yes"
/>
<get-auto-deploy-dir />
<copy
file="${plugin.war}"
todir="${auto.deploy.dir}"
/>
<var name="plugin.war" unset="true" />
</then>
<elseif>
<contains string="${plugin.path}" substring="${project.dir}/modules/" />
<then>
<gradle-execute dir="${plugin.path}" task="deploy" />
</then>
</elseif>
<else>
<ant dir="${plugin.path}" inheritAll="false" target="clean" />
<ant dir="${plugin.path}" inheritAll="false" target="deploy" />
</else>
</if>
<if>
<equals arg1="@{plugin}" arg2="cas-web" />
<then>
<move
todir="${app.server.dir}/webapps"
>
<fileset
dir="${app.server.dir}/webapps"
>
<include name="cas-web-*.war" />
</fileset>
<mapper
from="*"
to="cas-web.war"
type="glob"
/>
</move>
</then>
</if>
</else>
</if>
</sequential>
</for>
<delete dir="${lp.plugins.dir}/dist" />
<mkdir dir="${lp.plugins.dir}/dist" />
</target>
<target name="test-plugin">
<echo>Compiling ${test.plugin}.</echo>
<if>
<or>
<contains string="${test.plugin}" substring="layouttpl" />
<contains string="${test.plugin}" substring="shared" />
</or>
<then>
<var name="select" value="\2" />
</then>
<else>
<var name="select" value="\2s" />
</else>
</if>
<if>
<equals arg1="${test.plugin}" arg2="portal-http-service" />
<then>
<var name="test.plugin.type" value="shared" />
</then>
<else>
<propertyregex
input="${test.plugin}"
override="true"
property="test.plugin.type"
regexp="(\w+-)+(\w+)"
select="${select}"
/>
</else>
</if>
<ant dir="${lp.plugins.dir}/${test.plugin.type}/${test.plugin}" inheritAll="false" target="clean" />
<if>
<contains string="${test.plugin}" substring="portlet" />
<then>
<ant dir="${lp.plugins.dir}/${test.plugin.type}/${test.plugin}" inheritAll="false" target="compile-jsp" />
</then>
<else>
<ant dir="${lp.plugins.dir}/${test.plugin.type}/${test.plugin}" inheritAll="false" target="compile" />
</else>
</if>
</target>
<target name="test-plugin-group">
<if>
<not>
<isset property="test.plugin.group.index" />
</not>
<then>
<fail>Use "ant test-plugin-group -Dtest.plugin.group.index=0".</fail>
</then>
</if>
<set-plugins-build-properties />
<property file="${project.dir}/test.plugin.names.properties" />
<propertycopy from="TEST_PLUGIN_GROUP_${test.plugin.group.index}" name="test.plugins" />
<for list="${test.plugins}" param="test.plugin">
<sequential>
<trycatch property="test.plugin.exception">
<try>
<antcall target="test-plugin">
<param name="test.plugin" value="@{test.plugin}" />
</antcall>
</try>
<catch>
<echo>${test.plugin.exception}</echo>
<echo append="true" file="plugins-compile-failure">@{test.plugin},</echo>
</catch>
</trycatch>
</sequential>
</for>
<if>
<available file="plugins-compile-failure" />
<then>
<loadfile
property="failed.plugins"
srcFile="plugins-compile-failure"
/>
<beanshell>
<![CDATA[
StringBuilder sb = new StringBuilder();
sb.append("\n");
String failedPluginsString = project.getProperty("failed.plugins");
String[] failedPlugins = failedPluginsString.split(",");
sb.append(failedPlugins.length);
sb.append(" of ");
String testPluginsString = project.getProperty("test.plugins");
String[] testPlugins = testPluginsString.split(",");
sb.append(testPlugins.length);
sb.append(" plugin");
if (testPlugins.length != 1) {
sb.append("s");
}
sb.append(" failed to compile:\n");
for (String failedPlugin : failedPlugins) {
sb.append(failedPlugin);
sb.append("\n");
}
project.setProperty("plugins.failure.message", sb.toString());
]]>
</beanshell>
<fail message="${plugins.failure.message}" />
</then>
</if>
</target>
<target name="test-plugins">
<fail message="Please set the property ${lp.plugins.dir}" unless="lp.plugins.dir" />
<antcall target="record-test-plugin-names">
<param name="test.plugin.groups.size" value="1" />
</antcall>
<antcall target="test-plugin-group">
<param name="test.plugin.group.index" value="0" />
</antcall>
</target>
</project>