-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.xml
417 lines (361 loc) · 20.1 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
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
<!--
***********************************
Share Extras build script
***********************************
Author: Will Abson
Version: 1.5.1
Provides a set of targets for building extensions to Alfresco Share in ZIP, AMP and JAR archive
formats. Since Alfresco 3.3, JAR is the recommended package structure for all simple extensions.
For more complex extensions that add additional Java libraries, AMP should be used.
The following file structure is required in your project directory
/build.xml - This file
/config - All web-tier configuration files, e.g. web scripts and Surf configuration
/source/web - All static resource files, e.g. CSS, JS
For building AMP files, the files module.properties and file-mapping.properties are also required
in the project's root directory.
During the build process, temporary 'build' and 'dist' directories will be created in the base
project directory. These may be removed at any time using the 'clean' target.
-->
<project basedir="." default="dist-jar" name="Share Extras Build Script">
<!-- Allow override properties -->
<property file="build.properties" />
<property file="${user.home}/build.properties" />
<!-- Property default values. May be overridden using above files or via command-line args -->
<property name="jar.name" value="share-extension.jar" />
<property name="zip.name" value="share-extension.zip" />
<property name="amp.name" value="share-extension.amp" />
<property name="config.includes" value="**/*.*" />
<property name="config.excludes" value="" />
<property name="build.res.includes" value="**/*.*" />
<property name="build.res.excludes" value="" />
<property name="build.res.dir" value="webapps/share" />
<property name="build.classes.dir" value="shared/classes" />
<property name="build.lib.dir" value="shared/lib" />
<property name="yuicompress.warn" value="false" />
<!-- Tomcat properties to reload web scripts or the manager webapp -->
<property name="tomcat.url" value="http://localhost:8080" />
<property name="tomcat.repo.url" value="${tomcat.url}" />
<property name="tomcat.share.url" value="${tomcat.url}" />
<!-- Tomcat properties to reload web scripts -->
<property name="webapp.alfresco.path" value="/alfresco" />
<property name="webapp.share.path" value="/share" />
<property name="post.verbose" value="false" />
<property name="repo.admin.username" value="admin" />
<property name="repo.admin.password" value="admin" />
<property name="repo.scripts.index" value="${tomcat.repo.url}${webapp.alfresco.path}/service/index" />
<property name="share.scripts.index" value="${tomcat.share.url}${webapp.share.path}/page/index" />
<!-- Properties to access the Tomcat Manager application -->
<property name="webapp.manager.url" value="${tomcat.url}/manager" />
<property name="webapp.manager.username" value="admin" />
<property name="webapp.manager.password" value="" />
<!-- Paths to local Tomcat instances -->
<property name="tomcat.repo.home" value="${tomcat.home}" />
<property name="tomcat.share.home" value="${tomcat.home}" />
<!-- Additional property values. Generally should not be overridden -->
<property name="config.dir" value="${basedir}/config" />
<property name="res.dir" value="${basedir}/source/web" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.jar.dir" value="${build.dir}/jar" />
<property name="build.zip.dir" value="${build.dir}/war" />
<property name="build.amp.dir" value="${build.dir}/amp" />
<property name="dist.dir" value="${build.dir}/dist" />
<property name="amp.file.properties" value="module.properties" />
<property name="amp.file.mappings" value="file-mapping.properties" />
<!-- Define optional tasks -->
<!--
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" />
<taskdef name="post" classname="net.sf.antcontrib.net.PostTask" />
-->
<!-- Alias targets -->
<target name="build-zip" depends="build-zip-tomcat" />
<target name="dist-zip" depends="dist-zip-tomcat" />
<!-- Additional classpath and task definitions -->
<path id="yuicompressor.classpath">
<fileset dir="lib">
<include name="yuicompressor-2.4.2.jar"/>
<include name="yui-compressor-ant-task-0.5.jar"/>
</fileset>
</path>
<taskdef name="yuicompress" classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask">
<classpath>
<path refid="yuicompressor.classpath" />
</classpath>
</taskdef>
<path id="ml-ant-http.classpath">
<fileset dir="lib">
<include name="ml-ant-http-1.1.1.jar" />
</fileset>
</path>
<taskdef name="http" classname="org.missinglink.ant.task.http.HttpClientTask">
<classpath>
<path refid="ml-ant-http.classpath" />
</classpath>
</taskdef>
<!-- Main build target definitions -->
<!-- Clean out the build and distribution directories -->
<target name="clean" description="Clean out all build directories">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Create required prerequisite directory structure -->
<target name="prepare" description="Create initial build structures">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<!--
Assemble the configuration and resource files in a JAR file structure. This mechanism
was introduced in Alfresco 3.3 and allows Share extensions containing both repository and
web-tier web scripts, Spring/Surf configuration and static assets to be added to the servlet
container as a single library. For more complex extensions, AMP files should be used.
This target excludes the files custom-slingshot-application-context.xml, share-config-custom.xml
and similar files from being copied into the classpath as these should not generally be included
within JAR files as it could lead to multiple copies of them being present. If found however,
alfresco/web-extension/share-config-custom.xml will be copied into the META-INF directory,
from where it can be loaded in 3.4.
-->
<target name="build-jar" description="Assemble configuration and resource files in a JAR file structure">
<mkdir dir="${build.jar.dir}" />
<!-- Copy configuration files, web scripts, etc. directly into the JAR so they appear on the
classpath. -->
<copy todir="${build.jar.dir}" includeEmptyDirs="false">
<fileset dir="${config.dir}" includes="${config.includes}">
<!-- Spring config -->
<exclude name="web-application-config.xml" />
<exclude name="surf-config.xml" />
<exclude name="alfresco/slingshot-application-context.xml" />
<exclude name="alfresco/web-extension/custom-slingshot-application-context.xml" />
<!-- Surf config -->
<exclude name="alfresco/share*-config.xml" />
<exclude name="alfresco/web-extension/share-config-custom.xml" />
<exclude name="share-config-custom.xml" />
<!-- Global excludes -->
<exclude name="${config.excludes}" />
</fileset>
</copy>
<!-- Copy web-tier resources into the JAR. These can then be loaded by browsers via Share's resources
servlet by prefixing their path with '/res' -->
<mkdir dir="${build.jar.dir}/META-INF" />
<copy todir="${build.jar.dir}/META-INF" includeEmptyDirs="false">
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
</copy>
<!-- Map alfresco/web-extension/share-config-custom.xml to META-INF/share-config-custom.xml in the JAR -->
<copy todir="${build.jar.dir}/META-INF" includeEmptyDirs="false">
<fileset dir="${config.dir}">
<filename name="alfresco/web-extension/share-config-custom.xml" />
</fileset>
<globmapper from="alfresco/web-extension/*.xml" to="*.xml" handledirsep="true" />
</copy>
<copy todir="${build.jar.dir}/META-INF" includeEmptyDirs="false">
<fileset dir="${config.dir}">
<filename name="share-config-custom.xml" />
</fileset>
</copy>
<!-- Minify JS -->
<yuicompress fromdir="${res.dir}" todir="${build.jar.dir}/META-INF" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="**/*.js" />
</yuicompress>
</target>
<!-- Build the JAR file -->
<target name="dist-jar" depends="clean, prepare, build-jar"
description="Build a JAR file containing configuration and resource files">
<jar destfile="${dist.dir}/${jar.name}">
<fileset dir="${build.jar.dir}" />
</jar>
</target>
<!--
Assemble the configuration and resource files in a file structure suitable for deploying
into an existing Tomcat installation, with the following directories.
/shared/classes/alfresco Repository/Share configuration files
/webapps/share Share web resources
By default web resources are placed in directly in the 'share' web application. You
can specify a different directory by overriding the build.res.dir property value. Set
this to 'webapps/ROOT/share-extension' to use the pre-3.3 recommended layout.
The share-extension directory is not an official location for storing web resources
required by extensions but worked as an interim measure for versions of Alfresco prior to
version 3.3, provided that the ROOT webapp is enabled in your Tomcat instance.
By default configuration is placed in directly in Tomcat's shared/classes directory. You
can specify a different directory by overriding the build.classes.dir property value. Set
this to 'webapps/share/WEB-INF/classes' to place files on the classpath inside the webapp.
Unlike build-jar this target does not exclude any particular configuration files from the
file structure, however the hotcopy-tomcat-zip task will err on the side of caution and
will not copy files such as share-config-custom.xml itself into Tomcat.
-->
<target name="build-zip-tomcat" depends="build-zip-prepare,build-zip-config"
description="Assemble the configuration and resource files for a Tomcat deployment structure">
<!-- Copy web assets -->
<copy todir="${build.zip.dir}/${build.res.dir}">
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
</copy>
<!-- Minify JS -->
<yuicompress fromdir="${res.dir}" todir="${build.zip.dir}/${build.res.dir}" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="**/*.js" />
</yuicompress>
</target>
<target name="build-zip-prepare">
<mkdir dir="${build.zip.dir}/${build.classes.dir}" />
<mkdir dir="${build.zip.dir}/${build.res.dir}" />
</target>
<target name="build-zip-config">
<copy todir="${build.zip.dir}/${build.classes.dir}">
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}" />
</copy>
</target>
<!-- Build the Tomcat ZIP file -->
<target name="dist-zip-tomcat" depends="clean, prepare, build-zip-tomcat"
description="Build a ZIP file containing the customisations that can be deployed in an existing Tomcat installation">
<zip destfile="${dist.dir}/${zip.name}">
<fileset dir="${build.zip.dir}" />
</zip>
</target>
<!--
Assemble the configuration and resource files in an AMP file structure. The files
module.properties and file-mapping.properties must be present in the root of the
project.
This creates a structure which can be deployed into an exising share.war file using the
Alfresco Module Management Tool (MMT). See http://wiki.alfresco.com/wiki/AMP_Files.
This mechanism is compatible with all versions of Alfresco Share and can therefore be
used as an alternative to the JAR extension mechanism introduced in version 3.3.
Note that this mechanism will place files directly into the webapp structure when the
AMP is deployed, rather than the extension mechanisms used by the JAR and ZIP files that
ensure files are placed outside the webapp for safety during upgrades, etc.
In this case this should be acceptable since the MMT modifies the WAR file itself
rather than just the exploded files, and AMPs can always be re-applied if needed.
In version 3.3 and above the JAR file mechanism is recommended as an alternative for all
non-complex extensions.
-->
<target name="build-amp" description="Assemble the configuration and resource files in an AMP file structure">
<!-- Copy properties files -->
<copy todir="${build.amp.dir}" file="${amp.file.properties}" failonerror="true" />
<copy todir="${build.amp.dir}" file="${amp.file.mappings}" failonerror="true" />
<!-- Copy config files -->
<mkdir dir="${build.amp.dir}/config" />
<copy todir="${build.amp.dir}/config">
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}" />
</copy>
<!-- Copy resource files -->
<mkdir dir="${build.amp.dir}/web" />
<copy todir="${build.amp.dir}/web">
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
</copy>
<!-- Minify JS -->
<yuicompress fromdir="${res.dir}" todir="${build.amp.dir}/web" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="**/*.js" />
</yuicompress>
</target>
<!-- Build the AMP file -->
<target name="dist-amp" depends="clean, prepare, build-amp" description="Build an AMP file containing all customisations">
<zip destfile="${dist.dir}/${amp.name}">
<fileset dir="${build.amp.dir}" />
</zip>
</target>
<!-- Shared path definition used to copy files into the local Tomcat instance(s) -->
<patternset id="hotcopy-tomcat-zip-patternset">
<!-- Spring config -->
<exclude name="**/classes/web-application-config.xml" />
<exclude name="**/classes/surf-config.xml" />
<exclude name="**/classes/alfresco/slingshot-application-context.xml" />
<exclude name="**/classes/alfresco/web-extension/custom-slingshot-application-context.xml" />
<!-- Surf config -->
<exclude name="**/classes/alfresco/share*-config.xml" />
<exclude name="**/classes/alfresco/web-extension/share-config-custom.xml" />
</patternset>
<!--
Hot copy individual files into a local Tomcat instance.
In version 3.3 and above the JAR file mechanism is recommended for distributing your
customisations, but this target can still be used during development as it allows you to
reload changes without restarting Tomcat.
-->
<target name="hotcopy-tomcat-zip" depends="build-zip-tomcat" description="Hot copy individual files into a local Tomcat instance">
<echo message="Copying repository files" />
<copy todir="${tomcat.repo.home}" includeEmptyDirs="false">
<fileset dir="${build.zip.dir}">
<patternset refid="hotcopy-tomcat-zip-patternset" />
<!-- Exclude static resources -->
<exclude name="${build.res.dir}/**" />
<!-- Exclude web-tier config -->
<exclude name="**/classes/alfresco/site-webscripts/**" />
<exclude name="**/classes/alfresco/site-data/**" />
<exclude name="**/classes/alfresco/web-extension/**" />
<exclude name="**/classes/org/springframework/extensions/surf/**" />
</fileset>
</copy>
<echo message="Copying Share files" />
<copy todir="${tomcat.share.home}" includeEmptyDirs="false">
<fileset dir="${build.zip.dir}">
<patternset refid="hotcopy-tomcat-zip-patternset" />
<!-- Exclude repo-tier web scripts config -->
<exclude name="**/classes/alfresco/extension/**" />
<exclude name="**/classes/alfresco/templates/webscripts/**" />
</fileset>
</copy>
</target>
<!--
Hot copy JAR file into a local Tomcat instance.
-->
<target name="hotcopy-tomcat-jar" depends="dist-jar" description="Hot copy JAR file into a local Tomcat instance">
<mkdir dir="${tomcat.repo.home}/${build.lib.dir}" />
<mkdir dir="${tomcat.share.home}/${build.lib.dir}" />
<copy todir="${tomcat.repo.home}/${build.lib.dir}">
<fileset file="${dist.dir}/${jar.name}" />
</copy>
<copy todir="${tomcat.share.home}/${build.lib.dir}">
<fileset file="${dist.dir}/${jar.name}" />
</copy>
</target>
<!--
Web script reloading from Ant. These tasks use the HTTP task from
http://code.google.com/p/missing-link/.
-->
<target name="reload-webscripts-repo" depends="" description="Reload repository webscripts">
<http url="${repo.scripts.index}"
method="POST"
printrequest="false"
printrequestheaders="false"
printresponse="false"
printresponseheaders="false"
expected="200"
failonunexpected="true">
<credentials username="${repo.admin.username}" password="${repo.admin.password}" />
<query>
<parameter name="reset" value="on" />
</query>
</http>
</target>
<target name="reload-webscripts-share" depends="" description="Reload Share webscripts">
<http url="${share.scripts.index}"
method="POST"
printrequest="false"
printrequestheaders="false"
printresponse="false"
printresponseheaders="false"
expected="200"
failonunexpected="true">
<credentials username="${repo.admin.username}" password="${repo.admin.password}" />
<query>
<parameter name="reset" value="on" />
</query>
</http>
</target>
<!--
Uncomment to enable web application reloading from Ant. These tasks use the optional Tomcat
ant tasks from catalina-ant.jar distributed with Tomcat.
To use these tasks you will need to add catalina-ant.jar to your Ant libs and uncomment the
task definitions at the start of this file.
-->
<!--
<target name="reload-webapp-alfresco" description="Reload alfresco web application" depends="">
<reload
url="${webapp.manager.url}"
username="${webapp.manager.username}"
password="${webapp.manager.password}"
path="${webapp.alfresco.path}"/>
</target>
<target name="reload-webapp-share" description="Reload share web application" depends="">
<reload
url="${webapp.manager.url}"
username="${webapp.manager.username}"
password="${webapp.manager.password}"
path="${webapp.share.path}"/>
</target>
-->
</project>