forked from alkacon/alkacon-oamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-single.xml
429 lines (379 loc) · 14.9 KB
/
build-single.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Alkacon OpenCms Add-On Module Package" default="dist" basedir=".">
<property name="opencms.input" location="${basedir}/../OpenCms" />
<property name="opencms.output" location="${basedir}/../BuildOamp" />
<property name="opencms.input.warfiles" location="${opencms.input}/webapp" />
<property name="opencms.input.libs.runtime" location="${opencms.input}/lib/runtime" />
<property name="opencms.input.libs.compile" location="${opencms.input}/lib/compile" />
<property name="opencms.core.lib" location="${opencms.output}/build/jars-core" />
<property name="module.input" location="${basedir}/${module.name}" />
<property name="module.input.res" location="${module.input}/resources" />
<property name="module.input.lib" location="${module.input.res}/system/modules/${module.name}/lib" />
<property name="module.input.src" location="${module.input}/src" />
<property name="module.output.classes" location="${opencms.output}/build/classes-${module.name}" />
<property name="module.output.jar" location="${opencms.output}/build/jars-${module.name}" />
<property name="module.output.zip" location="${opencms.output}/zip" />
<property name="app.name" location="opencms" />
<property name="jar.excludes" value="**/CVS/*,**/.cvsignore,**/.nbattrs,**/.project,**/.classpath" />
<property name="zip.excludes" value="**/CVS/*,**/.cvsignore,**/.nbattrs,**/.project,**/.classpath" />
<property name="jar.includes" value="**/*.properties,**/*.txt,**/*.dtd,**/*.xml,**/*.xsd" />
<property environment="env" />
<property file="${basedir}/alkacon.properties" />
<taskdef resource="net/sf/antcontrib/antlib.xml" loaderref="contrib">
<classpath>
<pathelement location="${opencms.input.libs.compile}/ant-contrib-1.0b1.jar" />
</classpath>
</taskdef>
<taskdef resource="org/opencms/util/ant/taskdefs.properties" loaderref="opencms">
<classpath>
<pathelement location="${opencms.input.libs.compile}/ant-opencms-1.1.jar" />
</classpath>
</taskdef>
<target name="clean" description="Deletes outputs">
<delete dir="${module.output.classes}" />
<delete dir="${module.output.jar}" />
<if>
<available file="${module.output.zip}" />
<then>
<delete>
<fileset dir="${module.output.zip}">
<include name="${module.name}_*.zip" />
</fileset>
</delete>
</then>
</if>
</target>
<!-- Checks if all required libraries are available -->
<target name="init">
<if>
<not>
<available file="${module.input}" type="dir" />
</not>
<then>
<echo message="Building OpenCms Module ${module.name} for OpenCms ${version.number}" />
<fail>Module Directory not found: ${module.input}</fail>
</then>
</if>
<if>
<not>
<or>
<available file="${module.input}/module.properties" />
<available file="${module.input.res}/manifest.xml" />
</or>
</not>
<then>
<echo message="Building OpenCms Module ${module.name} for OpenCms ${version.number}" />
<fail>No Module Configuration File found: ${module.input}/module.properties or ${module.input.res}/manifest.xml</fail>
</then>
</if>
<if>
<available file="${module.input.res}/manifest.xml" />
<then>
<readxmlproperty property="module.version" xmlfile="${module.input.res}/manifest.xml" element="export/module/version" />
<readxmlproperty property="module.dependencies" xmlfile="${module.input.res}/manifest.xml" element="export/module/dependencies/dependency" attribute="name" />
</then>
</if>
<property file="${module.input}/module.properties" />
<if>
<or>
<not>
<isset property="module.version" />
</not>
<equals arg1="${module.version}" arg2="" />
</or>
<then>
<echo message="Building OpenCms Module ${module.name} for OpenCms ${version.number}" />
<fail>Wrong Module configuration: not able to get the module version.</fail>
</then>
</if>
<for list="${module.dependencies}" param="dependency" trim="true">
<sequential>
<property name="@{dependency}.input" value="${basedir}/@{dependency}" />
<property name="@{dependency}.output.classes" location="${opencms.output}/build/classes-@{dependency}" />
<property name="@{dependency}.output.jar" location="${opencms.output}/build/jars-@{dependency}" />
<if>
<available file="${@{dependency}.input}/resources/manifest.xml" />
<then>
<readxmlproperty property="@{dependency}.module.version" xmlfile="${@{dependency}.input}/resources/manifest.xml" element="export/module/version" />
<readxmlproperty property="@{dependency}.module.dependencies" xmlfile="${@{dependency}.input}/resources/manifest.xml" element="export/module/dependencies/dependency" attribute="name" />
</then>
</if>
<property file="${@{dependency}.input}/module.properties" prefix="@{dependency}" />
<property name="@{dependency}.output.zip" location="${module.output.zip}/@{dependency}_${@{dependency}.module.version}.zip" />
<condition property="@{dependency}.available">
<and>
<available file="${@{dependency}.output.zip}" />
</and>
</condition>
</sequential>
</for>
<condition property="opencms.available">
<and>
<available file="${opencms.core.lib}/opencms.jar" />
</and>
</condition>
<if>
<not>
<isset property="module.libs" />
</not>
<then>
<property name="module.libs" value="" />
</then>
</if>
<for list="${module.libs}" param="library" trim="true">
<sequential>
<condition property="@{library}.available">
<and>
<available file="${opencms.input.libs.runtime}/@{library}" />
</and>
</condition>
</sequential>
</for>
<condition property="tomcat.home" value="${env.TOMCAT_HOME}">
<available file="${env.TOMCAT_HOME}" type="dir" />
</condition>
<condition property="tomcat.home" value="${env.CATALINA_HOME}">
<available file="${env.CATALINA_HOME}" type="dir" />
</condition>
<echo message="Building Alkacon Module ${module.name} ${module.version} for OpenCms ${version.number}" />
<echo message=" " />
<echo message="OpenCms core lib directory is: ${opencms.core.lib}" />
<echo message="OpenCms runtime lib directory is: ${opencms.input.libs.runtime}" />
<echo message="OpenCms compile lib directory is: ${opencms.input.libs.compile}" />
<echo message="OpenCms output directory is: ${opencms.output}" />
<echo message="Module input directory is: ${module.input}" />
<echo message="Module source directory is: ${module.input.src}" />
<echo message="Detected Java version: ${ant.java.version}" />
<echo message="Tomcat home is: ${tomcat.home}" />
<echo message="Excluded files in Jar: ${jar.excludes}" />
<echo message="Included files in Jar: ${jar.includes}" />
<echo message=" " />
<echo message="Module libraries: ${module.libs}" />
<echo message="Module dependencies: ${module.dependencies}" />
<echo message="Additional lib folder: ${module.input.lib}" />
</target>
<!-- Generates the opencms.jar if it is missing -->
<target name="buildcore" unless="opencms.available">
<echo message="Core opencms.jar missing, building it using ${opencms.input}/build.xml" />
<ant antfile="${opencms.input}/build.xml" target="jar" />
<antcall target="clean" />
</target>
<!-- Generates all the modules dependencies -->
<target name="builddeps">
<for list="${module.dependencies}" param="dependency" trim="true">
<sequential>
<if>
<not>
<istrue value="${@{dependency}.available}" />
</not>
<then>
<echo message="Module dependency @{dependency} is missing, building it" />
<if>
<available file="${@{dependency}.input}" type="dir" />
<then>
<ant antfile="${basedir}/build.xml" target="dependencies" inheritAll="false">
<property name="module.name" value="@{dependency}" />
</ant>
</then>
<else>
<ant antfile="${opencms.input}/modules/build.xml" target="dependencies" inheritAll="false">
<property name="module.name" value="@{dependency}" />
</ant>
</else>
</if>
</then>
</if>
</sequential>
</for>
</target>
<!-- Stop target if libraries required for compilation are missing -->
<target name="checklibs" depends="init, buildcore, builddeps">
<var name="module.libs.missing" value="" />
<for list="${module.libs}" param="library" trim="true">
<sequential>
<if>
<not>
<isset property="@{library}.available" />
</not>
<then>
<var name="module.libs.missing" value="${module.libs.missing}," />
</then>
</if>
</sequential>
</for>
<if>
<not>
<equals arg1="${module.libs.missing}" arg2="" />
</not>
<then>
<echo message="Error: Some of the required libraries are not available." />
<echo message="To compile this module, you need the following libaries:" />
<echo message="${module.libs}" />
<echo message="which should be located in ${opencms.input.libs.runtime}" />
<fail>Required libraries missing</fail>
</then>
</if>
</target>
<target name="compile" depends="init, buildcore, builddeps" description="Compiles ${module.name} module classes">
<if>
<available file="${module.input.src}" />
<then>
<mkdir dir="${module.output.classes}" />
<!-- Create the classpath -->
<!-- A) The code of the dependency modules (module jar) itself in the build directory (jars-<module>)-->
<var name="module.dependencies.path" value="." />
<for list="${module.dependencies}" param="dependency" trim="true">
<sequential>
<if>
<available file="${@{dependency}.output.jar}" />
<then>
<for param="archive">
<fileset dir="${@{dependency}.output.jar}">
<include name="**/*.jar" />
</fileset>
<sequential>
<var name="module.dependencies.path" value="${module.dependencies.path}:@{archive}" />
</sequential>
</for>
</then>
</if>
</sequential>
</for>
<echo message="module.dependencies.path: ${module.dependencies.path}" />
<!-- B) The libraries of opencms -->
<var name="module.libs.path" value="." />
<for list="${module.libs}" param="library" trim="true">
<sequential>
<var name="module.libs.path" value="${module.libs.path}:${opencms.input.libs.runtime}/@{library}" />
</sequential>
</for>
<!-- C) The libraries of the module (<modulefolder>/libs/*.jar) -->
<if>
<available file="${module.input.lib}" />
<then>
<for param="archive">
<path>
<fileset dir="${module.input.lib}" includes="*.jar" />
</path>
<sequential>
<var name="module.libs.path" value="${module.libs.path}:${module.input.lib}/@{archive}" />
</sequential>
</for>
</then>
</if>
<echo message="module.libs.path: ${module.libs.path}" />
<!-- D) The libraries of the dependency - modules (<modulefolder>/libs/*.jar) -->
<var name="module.dependencies.libs" value="." />
<for list="${module.dependencies}" param="dependency">
<sequential>
<if>
<!--
This assumes that the dependency module is in the same project: OpenCms Modules
because module.input is set hardcoded to "${basedir}".
Support for including libs of dependencies in project OpenCms has to be added when
required in future!!!
-->
<available file="${@{dependency}.input}" />
<then>
<for param="archive">
<fileset dir="${@{dependency}.input}">
<include name="**/*.jar" />
</fileset>
<sequential>
<var name="module.dependencies.libs" value="${module.dependencies.libs}:@{archive}" />
</sequential>
</for>
</then>
</if>
</sequential>
</for>
<javac srcdir="${module.input}/src" destdir="${module.output.classes}" debug="on" optimize="on" deprecation="on" source="1.5" target="1.5">
<exclude name="**/test/**/*.java" />
<classpath>
<fileset dir="${opencms.input.libs.runtime}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${opencms.input.libs.compile}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${opencms.core.lib}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${module.dependencies.path}" />
<pathelement path="${module.libs.path}" />
<pathelement path="${module.dependencies.libs}" />
</classpath>
</javac>
<copy todir="${module.output.classes}">
<fileset dir="${module.input}/src" includes="${jar.includes}" excludes="${jar.excludes}">
<exclude name="**/test/**" />
</fileset>
</copy>
</then>
</if>
</target>
<target name="jar" depends="compile" description="Generates the .jar file for module ${module.name}">
<if>
<available file="${module.input.src}" />
<then>
<mkdir dir="${module.output.jar}" />
<jar jarfile="${module.output.jar}/${module.name}.jar" basedir="${module.output.classes}" />
<for list="${module.dependencies}" param="dependency" trim="true">
<sequential>
<if>
<available file="${@{dependency}.output.jar}" />
<then>
<copy todir="${module.output.jar}">
<fileset dir="${@{dependency}.output.jar}" includes="*.jar" />
</copy>
</then>
</if>
</sequential>
</for>
</then>
</if>
</target>
<target name="dist" depends="jar" description="Builds the distribution .zip file">
<mkdir dir="${module.output.zip}" />
<if>
<and>
<available file="${module.output.jar}" />
<available file="${module.input.res}" type="dir" />
</and>
<then>
<zip destfile="${module.output.zip}/${module.name}_${module.version}.zip">
<zipfileset dir="${module.output.jar}" prefix="system/modules/${module.name}/lib/" includes="${module.name}.jar" />
<zipfileset dir="${module.input.res}" prefix="" excludes="${zip.excludes}" />
</zip>
</then>
<else>
<if>
<available file="${module.input.res}" type="dir" />
<then>
<zip destfile="${module.output.zip}/${module.name}_${module.version}.zip">
<zipfileset dir="${module.input.res}" prefix="" excludes="${zip.excludes}" />
</zip>
</then>
</if>
</else>
</if>
</target>
<target name="tomcat.copy" depends="dist" description="Copies module resources to Tomcat directory">
<if>
<available file="${module.output.jar}" />
<then>
<copy todir="${tomcat.home}/webapps/${app.name}/WEB-INF/lib">
<fileset dir="${module.output.jar}" includes="*.jar" />
</copy>
</then>
</if>
<if>
<available file="${module.output.zip}/${module.name}_${module.version}.zip" />
<then>
<copy file="${module.output.zip}/${module.name}_${module.version}.zip" todir="${tomcat.home}/webapps/${app.name}/WEB-INF/packages/modules" />
</then>
</if>
</target>
<target name="tomcat.update" depends="tomcat.copy" description="Recompile changes and installs them in Tomcat webapps directory" />
<target name="tomcat.all" depends="clean, tomcat.update" description="Does a complete recompile of the module and installs it in Tomcat webapps directory" />
</project>