forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-common-plugin.xml
448 lines (371 loc) · 13.2 KB
/
build-common-plugin.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
<?xml version="1.0"?>
<project name="build-common-plugin" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-common.xml" />
<if>
<available file="docroot/WEB-INF/liferay-plugin-package.properties" />
<then>
<property file="docroot/WEB-INF/liferay-plugin-package.properties" prefix="plugin-package" />
<property name="plugin.version" value="${plugin-package.module-incremental-version}" />
<property file="docroot/WEB-INF/liferay-plugin-package.properties" prefix="plugin-package" />
<property name="plugin.jars" value="${plugin-package.portal.dependency.jars}" />
<property file="docroot/WEB-INF/liferay-plugin-package.properties" prefix="plugin-package" />
<property name="plugin.tlds" value="${plugin-package.portal.dependency.tlds}" />
</then>
</if>
<antelope:stringutil string="${basedir}" property="plugin.name.beginindex">
<antelope:lastindexof string="${file.separator}" />
</antelope:stringutil>
<antelope:math
datatype="int"
operand1="${plugin.name.beginindex}"
operand2="1"
operation="+"
result="plugin.name.beginindex"
/>
<antelope:stringutil string="${basedir}" property="plugin.name">
<antelope:substring beginindex="${plugin.name.beginindex}" />
</antelope:stringutil>
<if>
<antelope:endswith string="${plugin.name}" with="-client" />
<then>
<property name="plugin.file" value="${project.dir}/dist/${plugin.name}-${lp.version}.${plugin.version}.jar" />
</then>
<else>
<property name="plugin.file" value="${project.dir}/dist/${plugin.name}-${lp.version}.${plugin.version}.war" />
</else>
</if>
<target name="all">
<antcall target="clean" />
<antcall target="deploy" />
</target>
<target name="clean" description="clean">
<delete dir="docroot/WEB-INF/classes" />
<delete dir="tmp" />
<delete file="${plugin.file}" />
<antcall target="clean-portal-dependencies" />
</target>
<target name="clean-portal-dependencies">
<if>
<available file="docroot/WEB-INF/lib" />
<then>
<delete>
<fileset dir="docroot/WEB-INF/lib" includes="${required.portal.jars}" />
<fileset dir="docroot/WEB-INF/lib" includes="${plugin.jars}" />
</delete>
</then>
</if>
<if>
<available file="docroot/WEB-INF/tld" />
<then>
<delete>
<fileset dir="docroot/WEB-INF/tld" includes="${plugin.tlds}" />
</delete>
</then>
</if>
</target>
<target name="compile">
<antcall target="merge" />
<for param="js.file">
<path>
<fileset dir="docroot" includes="unpacked.js" />
</path>
<sequential>
<antelope:stringutil string="@{js.file}" property="js.file.unix">
<antelope:replace regex="\\" replacement="/" />
</antelope:stringutil>
<antelope:grep in="${js.file.unix}" regex="(.*/)(.*)" group="1" property="js.dir" />
<antcall target="build-javascript-cmd">
<param name="js.from.file" value="${js.file.unix}" />
<param name="js.to.file" value="${js.dir}packed.js" />
</antcall>
</sequential>
</for>
<mkdir dir="docroot/WEB-INF/classes" />
<mkdir dir="docroot/WEB-INF/lib" />
<copy todir="docroot/WEB-INF/lib">
<fileset dir="${app.server.lib.portal.dir}" includes="${plugin.jars}" />
</copy>
<copy todir="docroot/WEB-INF/tld">
<fileset dir="${app.server.portal.dir}/WEB-INF/tld" includes="${plugin.tlds}" />
</copy>
<if>
<available file="docroot/WEB-INF/src" />
<then>
<if>
<available file="tmp" />
<then>
<path id="plugin-lib.classpath">
<fileset dir="docroot/WEB-INF/lib" includes="*.jar" />
<fileset dir="tmp/WEB-INF/lib" includes="*.jar" />
<pathelement location="docroot/WEB-INF/classes" />
<pathelement location="tmp/WEB-INF/classes" />
</path>
</then>
<else>
<path id="plugin-lib.classpath">
<fileset dir="docroot/WEB-INF/lib" includes="*.jar" />
<pathelement location="docroot/WEB-INF/classes" />
</path>
</else>
</if>
<copy todir="docroot/WEB-INF/lib">
<fileset dir="${app.server.lib.portal.dir}" includes="${required.portal.jars}" />
</copy>
<if>
<equals arg1="${javac.compiler}" arg2="modern" />
<then>
<javac
classpathref="plugin.classpath"
compiler="${javac.compiler}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
destdir="docroot/WEB-INF/classes"
fork="${javac.fork}"
memoryMaximumSize="${javac.memoryMaximumSize}"
nowarn="${javac.nowarn}"
srcdir="docroot/WEB-INF/src"
/>
</then>
<else>
<javac
classpathref="plugin.classpath"
compiler="${javac.compiler}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
destdir="docroot/WEB-INF/classes"
nowarn="${javac.nowarn}"
srcdir="docroot/WEB-INF/src"
/>
</else>
</if>
<copy todir="docroot/WEB-INF/classes">
<fileset dir="docroot/WEB-INF/src" excludes="**/*.java" />
</copy>
</then>
</if>
<antcall target="merge" />
</target>
<target name="war" depends="compile">
<mkdir dir="${project.dir}/dist" />
<if>
<available file="tmp" />
<then>
<property name="docroot.dir" value="tmp" />
</then>
<else>
<property name="docroot.dir" value="docroot" />
</else>
</if>
<delete file="${plugin.file}" />
<antcall target="clean-portal-dependencies" />
<if>
<contains string="${app.server.dir}" substring="glassfish" />
<then>
<zip
basedir="${docroot.dir}"
destfile="${plugin.file}"
excludes="**/META-INF/context.xml"
/>
</then>
<else>
<zip
basedir="${docroot.dir}"
destfile="${plugin.file}"
/>
</else>
</if>
</target>
<target name="deploy" depends="war">
<copy file="${plugin.file}" todir="${auto.deploy.dir}" />
</target>
<target name="build-javascript-cmd">
<java
classname="com.yahoo.platform.yui.compressor.YUICompressor"
classpathref="lib.classpath"
fork="true"
newenvironment="true"
>
<arg line="--type js -o ${js.to.file} ${js.from.file}" />
</java>
</target>
<target name="build-lang-cmd">
<antcall target="build-lang-native2ascii-all" />
<java
classname="com.liferay.portal.tools.LangBuilder"
classpathref="portal.classpath"
fork="true"
newenvironment="true"
>
<jvmarg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" />
<jvmarg value="-Dfile.encoding=UTF-8" />
<jvmarg value="-Duser.country=US" />
<jvmarg value="-Duser.language=en" />
<arg value="${lang.dir}" />
<arg value="${lang.file}" />
</java>
<antcall target="build-lang-native2ascii-all" />
<copy file="${lang.dir}/${lang.file}.properties" tofile="${lang.dir}/${lang.file}_en.properties" />
<delete file="alfresco.log" />
</target>
<target name="build-lang-native2ascii">
<delete file="${lang.dir}/${lang.file}_${lang.code}.properties" failonerror="false" />
<exec dir="${lang.dir}" executable="cmd.exe" os="${os.windows}">
<arg line="/c '${env.JAVA_HOME}'/bin/native2ascii -encoding UTF-8 ${lang.file}_${lang.code}.properties.native ${lang.file}_${lang.code}.properties" />
</exec>
<exec dir="${lang.dir}" executable="${env.JAVA_HOME}/bin/native2ascii" os="${os.unix}">
<arg line="-encoding UTF-8 ${lang.file}_${lang.code}.properties.native ${lang.file}_${lang.code}.properties" />
</exec>
<exec dir="${lang.dir}" executable="/usr/bin/native2ascii" os="${os.apple}">
<arg line="-encoding UTF-8 ${lang.file}_${lang.code}.properties.native ${lang.file}_${lang.code}.properties" />
</exec>
</target>
<target name="build-lang-native2ascii-all">
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="ar" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="ca" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="zh_CN" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="zh_TW" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="cs" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="nl" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="fr" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="de" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="el" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="hu" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="it" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="ja" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="ko" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="pt" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="ru" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="es" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="sv" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="tr" />
</antcall>
<antcall target="build-lang-native2ascii">
<param name="lang.code" value="vi" />
</antcall>
</target>
<target name="build-service">
<mkdir dir="docroot/WEB-INF/classes" />
<mkdir dir="docroot/WEB-INF/lib" />
<mkdir dir="docroot/WEB-INF/service" />
<mkdir dir="docroot/WEB-INF/sql" />
<mkdir dir="docroot/WEB-INF/src" />
<copy todir="docroot/WEB-INF/classes">
<fileset dir="docroot/WEB-INF/src" excludes="**/*.java" />
</copy>
<path id="service.classpath">
<path refid="lib.classpath" />
<path refid="portal.classpath" />
<fileset dir="docroot/WEB-INF/lib" includes="*.jar" />
<pathelement location="docroot/WEB-INF/classes" />
</path>
<java
classname="com.liferay.portal.tools.servicebuilder.ServiceBuilder"
classpathref="service.classpath"
fork="true"
maxmemory="256m"
newenvironment="true"
>
<jvmarg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" />
<jvmarg value="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger" />
<jvmarg value="-Dservice.input.file=docroot/WEB-INF/service.xml" />
<jvmarg value="-Dservice.hbm.file=docroot/WEB-INF/src/META-INF/portlet-hbm.xml" />
<jvmarg value="-Dservice.model.hints.file=docroot/WEB-INF/src/META-INF/portlet-model-hints.xml" />
<jvmarg value="-Dservice.spring.file=docroot/WEB-INF/src/META-INF/portlet-spring.xml" />
<jvmarg value="-Dservice.spring.base.file=docroot/WEB-INF/src/META-INF/base-spring.xml" />
<jvmarg value="-Dservice.spring.hibernate.file=docroot/WEB-INF/src/META-INF/hibernate-spring.xml" />
<jvmarg value="-Dservice.spring.infrastructure.file=docroot/WEB-INF/src/META-INF/infrastructure-spring.xml" />
<jvmarg value="-Dservice.api.dir=docroot/WEB-INF/service" />
<jvmarg value="-Dservice.impl.dir=docroot/WEB-INF/src" />
<!--<jvmarg value="-Dservice.json.file=docroot/js/service_unpacked.js" />-->
<jvmarg value="-Dservice.sql.dir=docroot/WEB-INF/sql" />
<jvmarg value="-Dservice.sql.file=tables.sql" />
<jvmarg value="-Dservice.sql.indexes.file=indexes.sql" />
<jvmarg value="-Dservice.sql.indexes.properties.file=indexes.properties" />
<jvmarg value="-Dservice.sql.sequences.file=sequences.sql" />
<jvmarg value="-Dservice.auto.namespace.tables=true" />
<jvmarg value="-Dservice.bean.locator.util=com.liferay.util.bean.PortletBeanLocatorUtil" />
<jvmarg value="-Dservice.props.util=com.liferay.util.service.ServiceProps" />
<jvmarg value="-Dservice.plugin.name=${plugin.name}" />
</java>
<delete file="ServiceBuilder.temp" />
<!--<antcall target="build-javascript-cmd">
<param name="js.from.file" value="docroot/js/service_unpacked.js" />
<param name="js.to.file" value="docroot/js/service_packed.js" />
</antcall>-->
<mkdir dir="docroot/WEB-INF/service-classes" />
<delete file="docroot/WEB-INF/lib/${plugin.name}-service.jar" />
<path id="service.classpath">
<fileset dir="${app.server.lib.global.dir}" includes="*.jar" />
<fileset dir="docroot/WEB-INF/lib" excludes="${plugin.name}-service.jar" includes="*.jar" />
</path>
<javac
classpathref="service.classpath"
compiler="${javac.compiler}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
destdir="docroot/WEB-INF/service-classes"
nowarn="${javac.nowarn}"
srcdir="docroot/WEB-INF/service"
/>
<zip
basedir="docroot/WEB-INF/service-classes"
destfile="docroot/WEB-INF/lib/${plugin.name}-service.jar"
/>
<delete dir="docroot/WEB-INF/service-classes" />
</target>
<target name="merge" if="original.war.file">
<if>
<not>
<uptodate srcfile="${original.war.file}" targetfile="tmp" />
</not>
<then>
<delete dir="tmp" />
<mkdir dir="tmp" />
<mkdir dir="tmp/WEB-INF/classes" />
<mkdir dir="tmp/WEB-INF/lib" />
<unzip dest="tmp" src="${original.war.file}" />
<copy todir="tmp" overwrite="true">
<fileset dir="docroot" />
</copy>
</then>
</if>
<copy todir="tmp" overwrite="false">
<fileset dir="docroot" />
</copy>
</target>
</project>