forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-workspace.xml
231 lines (175 loc) · 7.19 KB
/
build-test-workspace.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
<?xml version="1.0"?>
<project basedir="." name="portal-test-workspace" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="deploy-workspace-client-extension">
<attribute default="" name="virtual.instance.id" />
<attribute name="workspace.client.extension.name" />
<sequential>
<var name="workspace.name" unset="true" />
<propertyregex
input="@{workspace.client.extension.name}"
property="workspace.name"
regexp="(liferay-[^-]+)-.*"
replace="\1-workspace"
/>
<var name="workspace.client.extension.dir" unset="true" />
<property name="workspace.client.extension.dir" value="${project.dir}/workspaces/${workspace.name}/client-extensions/@{workspace.client.extension.name}" />
<if>
<not>
<equals arg1="@{virtual.instance.id}" arg2="" />
</not>
<then>
<delete file="${workspace.client.extension.dir}/client-extension.poshi.yaml" />
<beanshell>
<![CDATA[
import com.liferay.jenkins.results.parser.JenkinsResultsParserUtil;
public List getClientExtensionIds() {
String fileContent = JenkinsResultsParserUtil.read(new File(project.getProperty("workspace.client.extension.dir"), "client-extension.yaml"));
List clientExtentionIds = new ArrayList();
String clientExtentionId = null;
for (String line : fileContent.split("\\n")) {
if (line.matches("([^:^\\s]+):")) {
clientExtentionId = line.replaceAll("([^:^\\s]+):", "$1");
}
if (clientExtentionId == null) {
continue;
}
if (line.matches("\\s{4}type: .+")) {
clientExtentionIds.add(clientExtentionId);
}
}
return clientExtentionIds;
}
StringBuilder sb = new StringBuilder();
for (String clientExtentionId : getClientExtensionIds()) {
sb.append(clientExtentionId);
sb.append(":\n dxp.lxc.liferay.com.virtualInstanceId: @{virtual.instance.id}\n");
}
JenkinsResultsParserUtil.write(new File(project.getProperty("workspace.client.extension.dir"), "client-extension.poshi.yaml"), sb.toString());
]]>
</beanshell>
<print-file file.name="${workspace.client.extension.dir}/client-extension.poshi.yaml" />
</then>
</if>
<if>
<available file="${workspace.client.extension.dir}" />
<then>
<gradle-execute dir="${workspace.client.extension.dir}" task="clean" />
<gradle-execute dir="${workspace.client.extension.dir}" task="deployPoshi" />
<copy
file="${workspace.client.extension.dir}/dist/@{workspace.client.extension.name}.zip"
todir="${liferay.home}/deploy"
/>
<if>
<not>
<equals arg1="@{virtual.instance.id}" arg2="" />
</not>
<then>
<wait-for-client-extension-deployment
client.extension.deploy.log="STARTED @{workspace.client.extension.name}_"
/>
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="deploy-workspace-client-extensions">
<sequential>
<propertycopy from="workspaces.client.extension.names[${workspace.name}]" name="workspaces.client.extension.names" override="true" />
<for list="${workspaces.client.extension.names}" param="workspace.client.extension.name">
<sequential>
<undeploy-workspace-client-extension workspace.client.extension.name="@{workspace.client.extension.name}" />
<deploy-workspace-client-extension workspace.client.extension.name="@{workspace.client.extension.name}" />
</sequential>
</for>
</sequential>
</macrodef>
<macrodef name="start-workspace">
<sequential>
<deploy-workspace-client-extensions />
</sequential>
</macrodef>
<macrodef name="stop-workspace">
<sequential>
</sequential>
</macrodef>
<macrodef name="undeploy-workspace-client-extension">
<attribute default="" name="virtual.instance.id" />
<attribute name="workspace.client.extension.name" />
<sequential>
<var name="workspace.name" unset="true" />
<propertyregex
input="@{workspace.client.extension.name}"
property="workspace.name"
regexp="(liferay-[^-]+)-.*"
replace="\1-workspace"
/>
<var name="workspace.client.extension.dir" unset="true" />
<property name="workspace.client.extension.dir" value="${project.dir}/workspaces/${workspace.name}/client-extensions/@{workspace.client.extension.name}" />
<if>
<available file="${liferay.home}/osgi/modules/@{workspace.client.extension.name}.zip" />
<then>
<delete file="${liferay.home}/osgi/modules/@{workspace.client.extension.name}.zip" />
<if>
<not>
<equals arg1="@{virtual.instance.id}" arg2="" />
</not>
<then>
<wait-for-client-extension-deployment
client.extension.deploy.log="STOPPED @{workspace.client.extension.name}_"
/>
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="wait-for-client-extension-deployment">
<attribute name="client.extension.deploy.log" />
<sequential>
<property name="client.extension.log" value="${project.dir}/client-extension-log" />
<delete file="${client.extension.log}" />
<record action="start" name="${client.extension.log}" />
<local name="deploy.client.extension.timeout" />
<waitfor checkevery="1" checkeveryunit="second" maxwait="30" maxwaitunit="second" timeoutproperty="deploy.client.extension.timeout">
<resourcecontains
resource="${client.extension.log}"
substring="@{client.extension.deploy.log}"
/>
</waitfor>
<record action="stop" name="${client.extension.log}" />
<delete file="${client.extension.log}" />
<if>
<isset property="deploy.client.extension.timeout" />
<then>
<echo>WARNING: Unable to confirm the client extension</echo>
</then>
</if>
</sequential>
</macrodef>
<target name="deploy-workspace-client-extension">
<fail message="Please set the property ${workspace.client.extension.name}." unless="workspace.client.extension.name" />
<condition else="" property="virtual.instance.id" value="${virtual.instance.id}">
<isset property="virtual.instance.id" />
</condition>
<undeploy-workspace-client-extension virtual.instance.id="${virtual.instance.id}" workspace.client.extension.name="${workspace.client.extension.name}" />
<deploy-workspace-client-extension virtual.instance.id="${virtual.instance.id}" workspace.client.extension.name="${workspace.client.extension.name}" />
</target>
<target name="start-workspace">
<fail message="Please set the property ${workspace.name}." unless="workspace.name" />
<stop-workspace />
<start-workspace />
</target>
<target name="stop-workspace">
<fail message="Please set the property ${workspace.name}." unless="workspace.name" />
<stop-workspace />
</target>
<target name="undeploy-workspace-client-extension">
<fail message="Please set the property ${workspace.client.extension.name}." unless="workspace.client.extension.name" />
<condition else="" property="virtual.instance.id" value="${virtual.instance.id}">
<isset property="virtual.instance.id" />
</condition>
<undeploy-workspace-client-extension virtual.instance.id="${virtual.instance.id}" workspace.client.extension.name="${workspace.client.extension.name}" />
</target>
</project>